From fa462b365715928d2c6eb52ca6a448f367084f0f Mon Sep 17 00:00:00 2001 From: practicalswift Date: Mon, 3 Sep 2018 15:41:02 +0200 Subject: [PATCH] wallet: Set encrypted_batch to nullptr after delete. Avoid double free in the case of NDEBUG. --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6cbfbc1f90..20ef80a1e5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -687,6 +687,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) { encrypted_batch->TxnAbort(); delete encrypted_batch; + encrypted_batch = nullptr; // We now probably have half of our keys encrypted in memory, and half not... // die and let the user reload the unencrypted wallet. assert(false); @@ -697,6 +698,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) if (!encrypted_batch->TxnCommit()) { delete encrypted_batch; + encrypted_batch = nullptr; // We now have keys encrypted in memory, but not on disk... // die to avoid confusion and let the user reload the unencrypted wallet. assert(false);