0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-09 10:43:19 -05:00

Use WITH_LOCK in Warnings::Set

The scope of the lock should be limited to just guarding m_warnings as
anything listening on `NotifyAlertChanged` may execute code that
requires the lock as well.
This commit is contained in:
Ava Chow 2024-07-06 13:00:53 -04:00
parent bd5d1688b4
commit 6af51e8198

View file

@ -28,8 +28,7 @@ Warnings::Warnings()
}
bool Warnings::Set(warning_type id, bilingual_str message)
{
LOCK(m_mutex);
const auto& [_, inserted]{m_warnings.insert({id, std::move(message)})};
const auto& [_, inserted]{WITH_LOCK(m_mutex, return m_warnings.insert({id, std::move(message)}))};
if (inserted) uiInterface.NotifyAlertChanged();
return inserted;
}