aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-07-01 17:16:39 +0800
committerfanquake <fanquake@gmail.com>2021-07-01 18:03:32 +0800
commitfa46e489820b8d663cf76001da74125b2140a3a6 (patch)
treece52774465e67945098118a2636049d7e6d761bf /src
parent3ef2d400fa42072a2cfe1cb51796c329e33ab8c5 (diff)
parentb945a31afac63010fce782b8fbca96dee6b458c5 (diff)
downloadbitcoin-fa46e489820b8d663cf76001da74125b2140a3a6.tar.xz
Merge bitcoin/bitcoin#22379: wallet: erase spkmans rather than setting to nullptr
b945a31afac63010fce782b8fbca96dee6b458c5 wallet: erase spkmans rather than setting to nullptr (Andrew Chow) Pull request description: In many places in ScriptPubKeyMan managing code, we assume that the ScriptPubKeyMan being retrieved actually exists and is not a nullptr. Thus removing a ScriptPubKeyMan requires erasing the object from the map rather than setting it to a nullptr. This fixes a segmentation fault that can be reached with `test/functional/wallet_descriptors.py --descriptors` ACKs for top commit: S3RK: ACK b945a31 Tree-SHA512: 344a4cf9b1c168428750c751dcd24c52032506f20c81977fe93c4b5307ea209de72bb62a9c5284820f225b03acdc9573fceb734833d29b82f49d5a799ddcaea7
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 1f736f8baf..173609e995 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3184,7 +3184,7 @@ void CWallet::LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool intern
spk_mans[type] = spk_man;
if (spk_mans_other[type] == spk_man) {
- spk_mans_other[type] = nullptr;
+ spk_mans_other.erase(type);
}
NotifyCanGetAddressesChanged();
@@ -3201,7 +3201,7 @@ void CWallet::DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool intern
}
auto& spk_mans = internal ? m_internal_spk_managers : m_external_spk_managers;
- spk_mans[type] = nullptr;
+ spk_mans.erase(type);
}
NotifyCanGetAddressesChanged();