]> git.sur5r.net Git - openldap/commitdiff
Fix mdb_node_move
authorHoward Chu <hyc@symas.com>
Sat, 21 Jun 2014 00:56:04 +0000 (17:56 -0700)
committerHoward Chu <hyc@symas.com>
Sat, 21 Jun 2014 00:56:04 +0000 (17:56 -0700)
Was leaving stale info in dst cursor

libraries/liblmdb/mdb.c

index 22629018c10703dad63855a016f8305d55acd73e..551519c150334076385098060242a011825d852c 100644 (file)
@@ -7054,20 +7054,20 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst)
                MDB_node *s2;
                MDB_val bkey;
                /* must find the lowest key below dst */
-               rc = mdb_page_search_lowest(cdst);
+               mdb_cursor_copy(cdst, &mn);
+               rc = mdb_page_search_lowest(&mn);
                if (rc)
                        return rc;
-               if (IS_LEAF2(cdst->mc_pg[cdst->mc_top])) {
-                       bkey.mv_size = cdst->mc_db->md_pad;
-                       bkey.mv_data = LEAF2KEY(cdst->mc_pg[cdst->mc_top], 0, bkey.mv_size);
+               if (IS_LEAF2(mn.mc_pg[mn.mc_top])) {
+                       bkey.mv_size = mn.mc_db->md_pad;
+                       bkey.mv_data = LEAF2KEY(mn.mc_pg[mn.mc_top], 0, bkey.mv_size);
                } else {
-                       s2 = NODEPTR(cdst->mc_pg[cdst->mc_top], 0);
+                       s2 = NODEPTR(mn.mc_pg[mn.mc_top], 0);
                        bkey.mv_size = NODEKSZ(s2);
                        bkey.mv_data = NODEKEY(s2);
                }
-               cdst->mc_snum = snum--;
-               cdst->mc_top = snum;
-               mdb_cursor_copy(cdst, &mn);
+               mn.mc_snum = snum--;
+               mn.mc_top = snum;
                mn.mc_ki[snum] = 0;
                rc = mdb_update_key(&mn, &bkey);
                if (rc)