]> git.sur5r.net Git - openldap/commitdiff
Fix CURSOR_NEXT/PREV on emptied DB
authorHoward Chu <hyc@symas.com>
Wed, 12 Jun 2013 00:13:08 +0000 (17:13 -0700)
committerHoward Chu <hyc@symas.com>
Wed, 12 Jun 2013 00:13:08 +0000 (17:13 -0700)
libraries/liblmdb/mdb.c

index a90d7d5510c853419d382630b6b32164bae19c4a..f52dda729141257e2f591bd835cf28a2383ab11a 100644 (file)
@@ -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]++;
                }