Skip to content

Commit 8e7cd22

Browse files
committed
ITS#8321 mdb_put cursor needs tracking too
1 parent 7881fd0 commit 8e7cd22

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libraries/liblmdb/mdb.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8658,7 +8658,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
86588658
m3->mc_ki[k+1] = m3->mc_ki[k];
86598659
m3->mc_pg[k+1] = m3->mc_pg[k];
86608660
}
8661-
if (m3->mc_ki[0] > nkeys) {
8661+
if (m3->mc_ki[0] >= nkeys) {
86628662
m3->mc_ki[0] = 1;
86638663
} else {
86648664
m3->mc_ki[0] = 0;
@@ -8700,6 +8700,7 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi,
87008700
{
87018701
MDB_cursor mc;
87028702
MDB_xcursor mx;
8703+
int rc;
87038704

87048705
if (!key || !data || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID))
87058706
return EINVAL;
@@ -8711,7 +8712,11 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi,
87118712
return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN;
87128713

87138714
mdb_cursor_init(&mc, txn, dbi, &mx);
8714-
return mdb_cursor_put(&mc, key, data, flags);
8715+
mc.mc_next = txn->mt_cursors[dbi];
8716+
txn->mt_cursors[dbi] = &mc;
8717+
rc = mdb_cursor_put(&mc, key, data, flags);
8718+
txn->mt_cursors[dbi] = mc.mc_next;
8719+
return rc;
87158720
}
87168721

87178722
#ifndef MDB_WBUF

0 commit comments

Comments
 (0)