Skip to content

Commit 6eeac2e

Browse files
committed
Merge #14138: wallet: Set encrypted_batch to nullptr after delete. Avoid double free in the case of NDEBUG.
fa462b3 wallet: Set encrypted_batch to nullptr after delete. Avoid double free in the case of NDEBUG. (practicalswift) Pull request description: Set `encrypted_batch` to `nullptr` after delete. Avoid double free in the case of `NDEBUG`. Tree-SHA512: 6f5ab40c82dd8c8713bbf1aacacdc837277c04769807f985248546be1c7ea269813c95379fbef982ac5683a45af0225613460a7446c39673b033f5f5edde2f5a
2 parents 3210756 + fa462b3 commit 6eeac2e

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)