From 8a99b00acc6fc737b825c979c057a98a081e4e68 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 25 Mar 2013 12:15:53 -0700 Subject: [PATCH] ITS#7553 deinit cursor after deleting last node --- libraries/liblmdb/mdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 3329565..ec003b7 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6403,7 +6403,7 @@ mdb_rebalance(MDB_cursor *mc) static int mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf) { - int rc; + int rc, eof; /* add overflow pages to free list */ if (!IS_LEAF2(mc->mc_pg[mc->mc_top]) && F_ISSET(leaf->mn_flags, F_BIGDATA)) { @@ -6421,9 +6421,12 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf) } mdb_node_del(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top], mc->mc_db->md_pad); mc->mc_db->md_entries--; + eof = mc->mc_flags & C_EOF; rc = mdb_rebalance(mc); if (rc != MDB_SUCCESS) mc->mc_txn->mt_flags |= MDB_TXN_ERROR; + else if (eof) + mc->mc_flags &= ~C_INITIALIZED; return rc; } -- 2.7.4