iter_t operators ++ and -- have some out-of-bounds issues
mzealey opened this issue · 0 comments
If you look up a record using lower_bound
and it is after the last key in the database; you can get a crash when trying to read or seek via the iterator (i cant remember which I did that caused the crash). You need to handle the --
case a bit like the patch I made here:
PowerDNS/pdns@0844062#diff-562825383c4b03c7c0504a94cfc4d2abR388
There is a similar issue with ++
, but it is slightly harder to solve as a SET_RANGE
will always return the next record ie it would only get into this state as the result of a --
and I'm not sure if it would do that even then - need to look at the lmdb docs. Lets say you were on the first record of the iterator and you --
it, I'm guessing d_end
goes to true
but you are actually at the beginning rather than the end. I think you probably need to keep track of both states and do a MDB_FIRST
type lookup, blanking a d_before_first
type flag...