mdbx: fix null-deref during MDBX_TXN_RDONLY_PREPARE in the MDBX_EXCLUSIVE mode.

Change-Id: I20b2bd4137293261a546910c8175be531d38b2c9
This commit is contained in:
Leonid Yuriev 2020-08-23 16:20:37 +03:00
parent bda4ebc939
commit c53627f5ac

View File

@ -6107,12 +6107,14 @@ static int mdbx_txn_renew0(MDBX_txn *txn, const unsigned flags) {
}
txn->to.reader = r;
if (flags & (MDBX_TXN_RDONLY_PREPARE - MDBX_TXN_RDONLY)) {
mdbx_assert(env, r->mr_txnid.inconsistent >= SAFE64_INVALID_THRESHOLD);
mdbx_assert(env, txn->mt_txnid == 0);
mdbx_assert(env, txn->mt_owner == 0);
mdbx_assert(env, txn->mt_numdbs == 0);
mdbx_assert(env, r->mr_snapshot_pages_used == 0);
r->mr_snapshot_pages_used = 0;
if (likely(r)) {
mdbx_assert(env, r->mr_snapshot_pages_used == 0);
mdbx_assert(env, r->mr_txnid.inconsistent >= SAFE64_INVALID_THRESHOLD);
r->mr_snapshot_pages_used = 0;
}
txn->mt_flags = MDBX_TXN_RDONLY | MDBX_TXN_FINISHED;
return MDBX_SUCCESS;
}