]> git.sur5r.net Git - openldap/commitdiff
ITS#8321 fix mdb_cursor_shadow()
authorHoward Chu <hyc@openldap.org>
Mon, 23 Nov 2015 01:13:16 +0000 (01:13 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 23 Nov 2015 01:40:56 +0000 (01:40 +0000)
Set a valid txn so that cursor fixup code works on the shadows

libraries/liblmdb/mdb.c

index c4f3c450a05e67c27f66292feb63cb25137935bf..4598a547468fc608ecd2ef0c63aa87791249b79a 100644 (file)
@@ -2558,14 +2558,15 @@ mdb_cursor_shadow(MDB_txn *src, MDB_txn *dst)
                                *bk = *mc;
                                mc->mc_backup = bk;
                                mc->mc_db = &dst->mt_dbs[i];
-                               /* Kill pointers into src - and dst to reduce abuse: The
-                                * user may not use mc until dst ends. Otherwise we'd...
+                               /* Kill pointers into src to reduce abuse: The
+                                * user may not use mc until dst ends. But we need a valid
+                                * txn pointer here for cursor fixups to keep working.
                                 */
-                               mc->mc_txn    = NULL;   /* ...set this to dst */
-                               mc->mc_dbflag = NULL;   /* ...and &dst->mt_dbflags[i] */
+                               mc->mc_txn    = dst;
+                               mc->mc_dbflag = &dst->mt_dbflags[i];
                                if ((mx = mc->mc_xcursor) != NULL) {
                                        *(MDB_xcursor *)(bk+1) = *mx;
-                                       mx->mx_cursor.mc_txn = NULL; /* ...and dst. */
+                                       mx->mx_cursor.mc_txn = dst;
                                }
                                mc->mc_next = dst->mt_cursors[i];
                                dst->mt_cursors[i] = mc;