diff options
author | warptangent <warptangent@tutanota.com> | 2016-02-13 03:41:22 -0800 |
---|---|---|
committer | warptangent <warptangent@tutanota.com> | 2016-02-13 04:17:37 -0800 |
commit | 9118d0a44c34ceb79368eae3b785b46f6ddf72b5 (patch) | |
tree | f848b7af602ccd393e2df1617e6aa9c9ce30329f /src/blockchain_db | |
parent | BlockchainLMDB: Replace remaining txn pointer NULLs with nullptr (diff) | |
download | monero-9118d0a44c34ceb79368eae3b785b46f6ddf72b5.tar.xz |
BlockchainLMDB: Call destructor on allocated txn if setup fails
Diffstat (limited to 'src/blockchain_db')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 2d116c532..3b3c5691b 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -2114,7 +2114,11 @@ void BlockchainLMDB::batch_start(uint64_t batch_num_blocks) // 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)) + { + 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())); + } // indicates this transaction is for batch transactions, but not whether it's // active m_write_batch_txn->m_batch_txn = true; @@ -2201,7 +2205,11 @@ void BlockchainLMDB::block_txn_start() { m_write_txn = new mdb_txn_safe(); 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())); + } } } |