From 1db9f32ae23330de44e86419991d64202ce9ac92 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 31 Jan 2017 10:41:52 +0000 Subject: [PATCH] Workaround VL32 cursor refcounting miscount Don't try to deref cursor page if txn's pagelist is empty --- libraries/liblmdb/mdb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 82bac14bbb..ec2488a89a 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -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; imc_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; imc_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; -- 2.39.5