Skip to content

Commit

Permalink
Merge #11007: wallet: Fix potential memory leak when loading a corrup…
Browse files Browse the repository at this point in the history
…ted 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
  • Loading branch information
laanwj committed Aug 22, 2017
2 parents 2ab7c63 + c06755f commit fc5c237
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/wallet/wallet.cpp
Expand Up @@ -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..."));
Expand Down

0 comments on commit fc5c237

Please sign in to comment.