mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 07:37:54 +00:00
Use unique_ptr for pdbCopy (Db) and fix potential memory leak
This commit is contained in:
parent
29ab96dbd2
commit
b45c597caa
@ -522,7 +522,7 @@ bool CDB::Rewrite(CWalletDBWrapper& dbw, const char* pszSkip)
|
|||||||
std::string strFileRes = strFile + ".rewrite";
|
std::string strFileRes = strFile + ".rewrite";
|
||||||
{ // surround usage of db with extra {}
|
{ // surround usage of db with extra {}
|
||||||
CDB db(dbw, "r");
|
CDB db(dbw, "r");
|
||||||
Db* pdbCopy = new Db(env->dbenv.get(), 0);
|
std::unique_ptr<Db> pdbCopy = std::unique_ptr<Db>(new Db(env->dbenv.get(), 0));
|
||||||
|
|
||||||
int ret = pdbCopy->open(nullptr, // Txn pointer
|
int ret = pdbCopy->open(nullptr, // Txn pointer
|
||||||
strFileRes.c_str(), // Filename
|
strFileRes.c_str(), // Filename
|
||||||
@ -571,7 +571,6 @@ bool CDB::Rewrite(CWalletDBWrapper& dbw, const char* pszSkip)
|
|||||||
} else {
|
} else {
|
||||||
pdbCopy->close(0);
|
pdbCopy->close(0);
|
||||||
}
|
}
|
||||||
delete pdbCopy;
|
|
||||||
}
|
}
|
||||||
if (fSuccess) {
|
if (fSuccess) {
|
||||||
Db dbA(env->dbenv.get(), 0);
|
Db dbA(env->dbenv.get(), 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user