Skip to content

Commit

Permalink
[wallet] Fix potential memory leak in CreateWalletFromFile
Browse files Browse the repository at this point in the history
Fix proposed by ryanofsky in
bitcoin#12647 (comment)
  • Loading branch information
John Newbery authored and PastaPastaPasta committed May 10, 2020
1 parent fcde41d commit 7649c32
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/wallet/wallet.cpp
Expand Up @@ -5160,7 +5160,6 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
}

walletInstance->m_last_block_processed = chainActive.Tip();
RegisterValidationInterface(walletInstance);

if (chainActive.Tip() && chainActive.Tip() != pindexRescan)
{
Expand Down Expand Up @@ -5226,6 +5225,10 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
}
}
}

// Register with the validation interface. It's ok to do this after rescan since we're still holding cs_main.
RegisterValidationInterface(temp_wallet.release());

walletInstance->SetBroadcastTransactions(gArgs.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));

{
Expand Down

0 comments on commit 7649c32

Please sign in to comment.