From: Howard Chu Date: Wed, 11 Jan 2017 10:33:28 +0000 (+0000) Subject: Tweak cursor_next C_EOF check X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=511f5880e22baddfe9fc1dee54b41a2deafc3b26;p=openldap Tweak cursor_next C_EOF check Allow C_EOF flag to be stale --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index c30a96f4c6..c84afef4dd 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6596,15 +6596,17 @@ mdb_cursor_next(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op) MDB_node *leaf; int rc; - if ((mc->mc_flags & C_EOF) || - ((mc->mc_flags & C_DEL) && op == MDB_NEXT_DUP)) { + if ((mc->mc_flags & C_DEL && op == MDB_NEXT_DUP)) return MDB_NOTFOUND; - } + if (!(mc->mc_flags & C_INITIALIZED)) return mdb_cursor_first(mc, key, data); mp = mc->mc_pg[mc->mc_top]; + if ((mc->mc_flags & C_EOF) && mc->mc_ki[mc->mc_top] >= NUMKEYS(mp)-1) + return MDB_NOTFOUND; + if (mc->mc_db->md_flags & MDB_DUPSORT) { leaf = NODEPTR(mp, mc->mc_ki[mc->mc_top]); if (F_ISSET(leaf->mn_flags, F_DUPDATA)) {