]> git.sur5r.net Git - openldap/commitdiff
Fix MDB_LAST, reset cursor index
authorHoward Chu <hyc@symas.com>
Sun, 21 Apr 2013 02:30:06 +0000 (19:30 -0700)
committerHoward Chu <hyc@symas.com>
Sun, 21 Apr 2013 02:30:06 +0000 (19:30 -0700)
libraries/liblmdb/mdb.c

index d3bb4da8ce560242fecab0ce919834dad6b1d50d..30475ac7e522ed9a654895bafcc1d3a76082b1ae 100644 (file)
@@ -4705,19 +4705,19 @@ mdb_cursor_last(MDB_cursor *mc, MDB_val *key, MDB_val *data)
 
        if (!(mc->mc_flags & C_EOF)) {
 
-       if (!(mc->mc_flags & C_INITIALIZED) || mc->mc_top) {
-               MDB_val lkey;
+               if (!(mc->mc_flags & C_INITIALIZED) || mc->mc_top) {
+                       MDB_val lkey;
 
-               lkey.mv_size = MDB_MAXKEYSIZE+1;
-               lkey.mv_data = NULL;
-               rc = mdb_page_search(mc, &lkey, 0);
-               if (rc != MDB_SUCCESS)
-                       return rc;
-       }
-       assert(IS_LEAF(mc->mc_pg[mc->mc_top]));
+                       lkey.mv_size = MDB_MAXKEYSIZE+1;
+                       lkey.mv_data = NULL;
+                       rc = mdb_page_search(mc, &lkey, 0);
+                       if (rc != MDB_SUCCESS)
+                               return rc;
+               }
+               assert(IS_LEAF(mc->mc_pg[mc->mc_top]));
 
-       mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]) - 1;
        }
+       mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]) - 1;
        mc->mc_flags |= C_INITIALIZED|C_EOF;
        leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);