mirror of
https://github.com/monero-project/monero.git
synced 2024-12-28 22:06:13 -05:00
BlockchainLMDB: Call destructor on allocated txn if setup fails
This commit is contained in:
parent
f5581c3536
commit
9118d0a44c
@ -2114,7 +2114,11 @@ void BlockchainLMDB::batch_start(uint64_t batch_num_blocks)
|
|||||||
|
|
||||||
// NOTE: need to make sure it's destroyed properly when done
|
// NOTE: need to make sure it's destroyed properly when done
|
||||||
if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, *m_write_batch_txn))
|
if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, *m_write_batch_txn))
|
||||||
|
{
|
||||||
|
delete m_write_batch_txn;
|
||||||
|
m_write_batch_txn = nullptr;
|
||||||
throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str()));
|
throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str()));
|
||||||
|
}
|
||||||
// indicates this transaction is for batch transactions, but not whether it's
|
// indicates this transaction is for batch transactions, but not whether it's
|
||||||
// active
|
// active
|
||||||
m_write_batch_txn->m_batch_txn = true;
|
m_write_batch_txn->m_batch_txn = true;
|
||||||
@ -2201,7 +2205,11 @@ void BlockchainLMDB::block_txn_start()
|
|||||||
{
|
{
|
||||||
m_write_txn = new mdb_txn_safe();
|
m_write_txn = new mdb_txn_safe();
|
||||||
if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, *m_write_txn))
|
if (auto mdb_res = mdb_txn_begin(m_env, NULL, 0, *m_write_txn))
|
||||||
|
{
|
||||||
|
delete m_write_txn;
|
||||||
|
m_write_txn = nullptr;
|
||||||
throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str()));
|
throw0(DB_ERROR(lmdb_error("Failed to create a transaction for the db: ", mdb_res).c_str()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user