wallet: Fix memory leak when loading a corrupted wallet file
This commit is contained in:
parent
140de14a12
commit
c06755f5cf
1 changed files with 1 additions and 4 deletions
|
@ -3937,15 +3937,12 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
|
||||||
uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
|
uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
|
||||||
|
|
||||||
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, walletFile));
|
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);
|
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
|
||||||
if (nZapWalletRet != DB_LOAD_OK) {
|
if (nZapWalletRet != DB_LOAD_OK) {
|
||||||
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
|
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete tempWallet;
|
|
||||||
tempWallet = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uiInterface.InitMessage(_("Loading wallet..."));
|
uiInterface.InitMessage(_("Loading wallet..."));
|
||||||
|
|
Loading…
Reference in a new issue