Skip to content

Commit fc5c237

Browse files
committed
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
2 parents 2ab7c63 + c06755f commit fc5c237

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
@@ -3934,15 +3934,12 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
39343934
uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
39353935

39363936
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, walletFile));
3937-
CWallet *tempWallet = new CWallet(std::move(dbw));
3937+
std::unique_ptr<CWallet> tempWallet(new CWallet(std::move(dbw)));
39383938
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
39393939
if (nZapWalletRet != DB_LOAD_OK) {
39403940
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
39413941
return nullptr;
39423942
}
3943-
3944-
delete tempWallet;
3945-
tempWallet = nullptr;
39463943
}
39473944

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

0 commit comments

Comments
 (0)