From: Howard Chu Date: Tue, 24 Nov 2015 01:21:05 +0000 (+0000) Subject: ITS#8321 mdb_put cursor needs tracking too X-Git-Tag: LMDB_0.9.17~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8e7cd2269d412c60f072b57086e6f5e7362609e5;p=openldap ITS#8321 mdb_put cursor needs tracking too --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 7b5e099534..e9c2c9f298 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -8658,7 +8658,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno m3->mc_ki[k+1] = m3->mc_ki[k]; m3->mc_pg[k+1] = m3->mc_pg[k]; } - if (m3->mc_ki[0] > nkeys) { + if (m3->mc_ki[0] >= nkeys) { m3->mc_ki[0] = 1; } else { m3->mc_ki[0] = 0; @@ -8700,6 +8700,7 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi, { MDB_cursor mc; MDB_xcursor mx; + int rc; if (!key || !data || !TXN_DBI_EXIST(txn, dbi, DB_USRVALID)) return EINVAL; @@ -8711,7 +8712,11 @@ mdb_put(MDB_txn *txn, MDB_dbi dbi, return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN; mdb_cursor_init(&mc, txn, dbi, &mx); - return mdb_cursor_put(&mc, key, data, flags); + mc.mc_next = txn->mt_cursors[dbi]; + txn->mt_cursors[dbi] = &mc; + rc = mdb_cursor_put(&mc, key, data, flags); + txn->mt_cursors[dbi] = mc.mc_next; + return rc; } #ifndef MDB_WBUF