Skip to content

Commit 1273fc2

Browse files
laanwjPastaPastaPasta
authored andcommitted
Merge bitcoin#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
1 parent 7253eb2 commit 1273fc2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5099,15 +5099,12 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
50995099
uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
51005100

51015101
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, walletFile));
5102-
CWallet *tempWallet = new CWallet(std::move(dbw));
5102+
std::unique_ptr<CWallet> tempWallet(new CWallet(std::move(dbw)));
51035103
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
51045104
if (nZapWalletRet != DB_LOAD_OK) {
51055105
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
51065106
return nullptr;
51075107
}
5108-
5109-
delete tempWallet;
5110-
tempWallet = nullptr;
51115108
}
51125109

51135110
uiInterface.InitMessage(_("Loading wallet..."));

0 commit comments

Comments
 (0)