cryptonote_core: fix db leak on error
This commit is contained in:
parent
213e326cc9
commit
8e60b81c48
|
@ -321,6 +321,7 @@ bool Blockchain::init(BlockchainDB* db, const bool testnet, bool offline, const
|
||||||
if (!db->is_open())
|
if (!db->is_open())
|
||||||
{
|
{
|
||||||
LOG_ERROR("Attempted to init Blockchain with unopened DB");
|
LOG_ERROR("Attempted to init Blockchain with unopened DB");
|
||||||
|
delete db;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -377,7 +377,7 @@ namespace cryptonote
|
||||||
// folder might not be a directory, etc, etc
|
// folder might not be a directory, etc, etc
|
||||||
catch (...) { }
|
catch (...) { }
|
||||||
|
|
||||||
BlockchainDB* db = new_db(db_type);
|
std::unique_ptr<BlockchainDB> db(new_db(db_type));
|
||||||
if (db == NULL)
|
if (db == NULL)
|
||||||
{
|
{
|
||||||
LOG_ERROR("Attempted to use non-existent database type");
|
LOG_ERROR("Attempted to use non-existent database type");
|
||||||
|
@ -468,7 +468,7 @@ namespace cryptonote
|
||||||
m_blockchain_storage.set_user_options(blocks_threads,
|
m_blockchain_storage.set_user_options(blocks_threads,
|
||||||
blocks_per_sync, sync_mode, fast_sync);
|
blocks_per_sync, sync_mode, fast_sync);
|
||||||
|
|
||||||
r = m_blockchain_storage.init(db, m_testnet, m_offline, test_options);
|
r = m_blockchain_storage.init(db.release(), m_testnet, m_offline, test_options);
|
||||||
|
|
||||||
r = m_mempool.init();
|
r = m_mempool.init();
|
||||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
|
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
|
||||||
|
|
Loading…
Reference in New Issue