Skip to content

Commit fa462b3

Browse files
wallet: Set encrypted_batch to nullptr after delete. Avoid double free in the case of NDEBUG.
1 parent 68f3c7e commit fa462b3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
687687
{
688688
encrypted_batch->TxnAbort();
689689
delete encrypted_batch;
690+
encrypted_batch = nullptr;
690691
// We now probably have half of our keys encrypted in memory, and half not...
691692
// die and let the user reload the unencrypted wallet.
692693
assert(false);
@@ -697,6 +698,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
697698

698699
if (!encrypted_batch->TxnCommit()) {
699700
delete encrypted_batch;
701+
encrypted_batch = nullptr;
700702
// We now have keys encrypted in memory, but not on disk...
701703
// die to avoid confusion and let the user reload the unencrypted wallet.
702704
assert(false);

0 commit comments

Comments
 (0)