aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2017-08-09 16:30:57 +0200
committerpracticalswift <practicalswift@users.noreply.github.com>2017-11-09 16:53:34 +0100
commitb45c597caadabbf10a1e34f2c9ee1d0916164eee (patch)
treed0b23ba9894f7764eb67a9d2e8344d477fcbbcdc /src
parent29ab96dbd2bc76152de6eff09755b1b66b29474d (diff)
Use unique_ptr for pdbCopy (Db) and fix potential memory leak
Diffstat (limited to 'src')
-rw-r--r--src/wallet/db.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index 520c16d9c6..cae8cd7dac 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -522,7 +522,7 @@ bool CDB::Rewrite(CWalletDBWrapper& dbw, const char* pszSkip)
std::string strFileRes = strFile + ".rewrite";
{ // surround usage of db with extra {}
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
strFileRes.c_str(), // Filename
@@ -571,7 +571,6 @@ bool CDB::Rewrite(CWalletDBWrapper& dbw, const char* pszSkip)
} else {
pdbCopy->close(0);
}
- delete pdbCopy;
}
if (fSuccess) {
Db dbA(env->dbenv.get(), 0);