From: Howard Chu Date: Tue, 29 Jan 2013 02:45:36 +0000 (-0800) Subject: ITS#7511 make sure cursor is marked valid after successful put X-Git-Tag: OPENLDAP_REL_ENG_2_4_34~22^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=27aaecc744955d08d2bfe7a3ca786d742267c5bd;p=openldap ITS#7511 make sure cursor is marked valid after successful put --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 0ef43d6154..cdd8ea104e 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4639,7 +4639,7 @@ mdb_cursor_get(MDB_cursor *mc, MDB_val *key, MDB_val *data, switch (op) { case MDB_GET_CURRENT: - if (!mc->mc_flags & C_INITIALIZED) { + if (!(mc->mc_flags & C_INITIALIZED)) { rc = EINVAL; } else { MDB_page *mp = mc->mc_pg[mc->mc_top]; @@ -5181,6 +5181,11 @@ put_sub: } } done: + /* If we succeeded and the key didn't exist before, make sure + * the cursor is marked valid. + */ + if (!rc && insert) + mc->mc_flags |= C_INITIALIZED; return rc; } @@ -5193,7 +5198,7 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags) if (F_ISSET(mc->mc_txn->mt_flags, MDB_TXN_RDONLY)) return EACCES; - if (!mc->mc_flags & C_INITIALIZED) + if (!(mc->mc_flags & C_INITIALIZED)) return EINVAL; rc = mdb_cursor_touch(mc);