Skip to content

Commit fa46e48

Browse files
committed
Merge bitcoin/bitcoin#22379: wallet: erase spkmans rather than setting to nullptr
b945a31 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
2 parents 3ef2d40 + b945a31 commit fa46e48

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@ void CWallet::LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool intern
31843184
spk_mans[type] = spk_man;
31853185

31863186
if (spk_mans_other[type] == spk_man) {
3187-
spk_mans_other[type] = nullptr;
3187+
spk_mans_other.erase(type);
31883188
}
31893189

31903190
NotifyCanGetAddressesChanged();
@@ -3201,7 +3201,7 @@ void CWallet::DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool intern
32013201
}
32023202

32033203
auto& spk_mans = internal ? m_internal_spk_managers : m_external_spk_managers;
3204-
spk_mans[type] = nullptr;
3204+
spk_mans.erase(type);
32053205
}
32063206

32073207
NotifyCanGetAddressesChanged();

0 commit comments

Comments
 (0)