Skip to content

Commit c06755f

Browse files
wallet: Fix memory leak when loading a corrupted wallet file
1 parent 140de14 commit c06755f

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

39393939
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, walletFile));
3940-
CWallet *tempWallet = new CWallet(std::move(dbw));
3940+
std::unique_ptr<CWallet> tempWallet(new CWallet(std::move(dbw)));
39413941
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
39423942
if (nZapWalletRet != DB_LOAD_OK) {
39433943
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
39443944
return nullptr;
39453945
}
3946-
3947-
delete tempWallet;
3948-
tempWallet = nullptr;
39493946
}
39503947

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

0 commit comments

Comments
 (0)