Merge #11007: wallet: Fix potential memory leak when loading a corrupted wallet file

c06755f wallet: Fix memory leak when loading a corrupted wallet file (practicalswift)

Pull request description:

  Fix potential memory leak when loading a corrupted wallet file.

Tree-SHA512: 4b836e4ee1fe4267213bb126af0c1174f964ff015fbe28d0a7e679eab877c275769906b3c08f885763958f6a9b559e1b5e6c7bff1df340bf2dfa2acd57500818
This commit is contained in:
Wladimir J. van der Laan 2017-08-22 09:42:34 +02:00
commit fc5c237d4a
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
1 changed files with 1 additions and 4 deletions

View File

@ -3934,15 +3934,12 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, walletFile));
CWallet *tempWallet = new CWallet(std::move(dbw));
std::unique_ptr<CWallet> tempWallet(new CWallet(std::move(dbw)));
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
if (nZapWalletRet != DB_LOAD_OK) {
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
return nullptr;
}
delete tempWallet;
tempWallet = nullptr;
}
uiInterface.InitMessage(_("Loading wallet..."));