From: Howard Chu Date: Wed, 12 Jun 2013 00:13:08 +0000 (-0700) Subject: Fix CURSOR_NEXT/PREV on emptied DB X-Git-Tag: OPENLDAP_REL_ENG_2_4_36~36^2~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c2cac4588a40480c020d320b544bc5f8e72adb11;p=openldap Fix CURSOR_NEXT/PREV on emptied DB --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index a90d7d5510..f52dda7291 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4935,9 +4935,11 @@ fetchm: case MDB_NEXT: case MDB_NEXT_DUP: case MDB_NEXT_NODUP: - if (!(mc->mc_flags & C_INITIALIZED)) + if (!(mc->mc_flags & C_INITIALIZED)) { rc = mdb_cursor_first(mc, key, data); - else + if (rc) + break; + } else rc = mdb_cursor_next(mc, key, data, op); break; case MDB_PREV: @@ -4945,6 +4947,8 @@ fetchm: case MDB_PREV_NODUP: if (!(mc->mc_flags & C_INITIALIZED)) { rc = mdb_cursor_last(mc, key, data); + if (rc) + break; mc->mc_flags |= C_INITIALIZED; mc->mc_ki[mc->mc_top]++; }