The previous implementation assumed that
lower_bound(parent_iter->key()) always leaves the iterator
on_parent(). There isn't any guarantee, however, that that
key isn't present on the child as well.
Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit
74a7631d0938d7b44894f022224eab10a90d5cec)
int DBObjectMap::DBObjectMapIteratorImpl::next_parent()
{
- if (!parent_iter || !parent_iter->valid()) {
- invalid = true;
- return 0;
- }
r = next();
if (r < 0)
return r;
- if (!valid() || on_parent() || !parent_iter->valid())
- return 0;
+ while (parent_iter && parent_iter->valid() && !on_parent()) {
+ assert(valid());
+ r = lower_bound(parent_iter->key());
+ if (r < 0)
+ return r;
+ }
- return lower_bound(parent_iter->key());
+ if (!parent_iter || !parent_iter->valid()) {
+ invalid = true;
+ }
+ return 0;
}
int DBObjectMap::DBObjectMapIteratorImpl::in_complete_region(const string &to_test,