Skip to content

Commit 00515ba

Browse files
committed
ITS#8321 deinit empty cursors
Always unset C_INIT flag if the cursor's target DB has been deleted
1 parent 75bca7f commit 00515ba

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

libraries/liblmdb/mdb.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5163,8 +5163,11 @@ mdb_cursor_pop(MDB_cursor *mc)
51635163
mc->mc_pg[mc->mc_top]->mp_pgno, DDBI(mc), (void *) mc));
51645164

51655165
mc->mc_snum--;
5166-
if (mc->mc_snum)
5166+
if (mc->mc_snum) {
51675167
mc->mc_top--;
5168+
} else {
5169+
mc->mc_flags &= ~C_INITIALIZED;
5170+
}
51685171
}
51695172
}
51705173

@@ -6820,6 +6823,7 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags)
68206823
if (flags & MDB_NODUPDATA) {
68216824
/* mdb_cursor_del0() will subtract the final entry */
68226825
mc->mc_db->md_entries -= mc->mc_xcursor->mx_db.md_entries - 1;
6826+
mc->mc_xcursor->mx_cursor.mc_flags &= ~C_INITIALIZED;
68236827
} else {
68246828
if (!F_ISSET(leaf->mn_flags, F_SUBDATA)) {
68256829
mc->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(leaf);
@@ -6857,6 +6861,8 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags)
68576861
mc->mc_db->md_entries--;
68586862
mc->mc_flags |= C_DEL;
68596863
return rc;
6864+
} else {
6865+
mc->mc_xcursor->mx_cursor.mc_flags &= ~C_INITIALIZED;
68606866
}
68616867
/* otherwise fall thru and delete the sub-DB */
68626868
}
@@ -9646,6 +9652,7 @@ mdb_drop0(MDB_cursor *mc, int subs)
96469652
} else if (rc == MDB_NOTFOUND) {
96479653
rc = MDB_SUCCESS;
96489654
}
9655+
mc->mc_flags &= ~C_INITIALIZED;
96499656
return rc;
96509657
}
96519658

0 commit comments

Comments
 (0)