mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
wallet: Reset chain notifications handler if AttachChain fails
AttachChain will create the chain notifications handler which contains a reference to the wallet's shared_ptr. If AttachChain fails, the wallet needs to be unloaded, and this is expected to happen with its custom deleter ReleaseWallet. However, if the chain notifications handler is still set, then the shared_ptr is still referenced by something, so the wallet is never actually released.
This commit is contained in:
parent
3ba8de1b70
commit
ea2551e55d
1 changed files with 1 additions and 0 deletions
|
@ -3099,6 +3099,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
if (time_first_key) walletInstance->MaybeUpdateBirthTime(*time_first_key);
|
||||
|
||||
if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) {
|
||||
walletInstance->m_chain_notifications_handler.reset(); // Reset this pointer so that the wallet will actually be unloaded
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue