]> git.sur5r.net Git - openldap/commitdiff
Workaround VL32 cursor refcounting miscount
authorHoward Chu <hyc@openldap.org>
Tue, 31 Jan 2017 10:41:52 +0000 (10:41 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 31 Jan 2017 10:41:52 +0000 (10:41 +0000)
Don't try to deref cursor page if txn's pagelist is empty

libraries/liblmdb/mdb.c

index 82bac14bbbcc677f19cfe43744fb91c5763c1a5c..ec2488a89a535c99a936e8e51b8e4843fc8cdfe0 100644 (file)
@@ -2006,13 +2006,15 @@ static void
 mdb_cursor_unref(MDB_cursor *mc)
 {
        int i;
-       if (!mc->mc_snum || !mc->mc_pg[0] || IS_SUBP(mc->mc_pg[0]))
-               return;
-       for (i=0; i<mc->mc_snum; i++)
-               mdb_page_unref(mc->mc_txn, mc->mc_pg[i]);
-       if (mc->mc_ovpg) {
-               mdb_page_unref(mc->mc_txn, mc->mc_ovpg);
-               mc->mc_ovpg = 0;
+       if (mc->mc_txn->mt_rpages[0].mid) {
+               if (!mc->mc_snum || !mc->mc_pg[0] || IS_SUBP(mc->mc_pg[0]))
+                       return;
+               for (i=0; i<mc->mc_snum; i++)
+                       mdb_page_unref(mc->mc_txn, mc->mc_pg[i]);
+               if (mc->mc_ovpg) {
+                       mdb_page_unref(mc->mc_txn, mc->mc_ovpg);
+                       mc->mc_ovpg = 0;
+               }
        }
        mc->mc_snum = mc->mc_top = 0;
        mc->mc_pg[0] = NULL;