fix: potential bug due to unspecified state of std::vector after move

This commit is contained in:
Konstantin Akimov 2024-11-26 01:47:41 +07:00
parent 8a05f0caaa
commit 83e0bb6e35
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
2 changed files with 3 additions and 8 deletions

View File

@ -520,10 +520,8 @@ void CSigningManager::CollectPendingRecoveredSigsToVerify(
void CSigningManager::ProcessPendingReconstructedRecoveredSigs()
{
decltype(pendingReconstructedRecoveredSigs) m;
{
LOCK(cs_pending);
m = std::move(pendingReconstructedRecoveredSigs);
}
WITH_LOCK(cs_pending, swap(m, pendingReconstructedRecoveredSigs));
for (const auto& p : m) {
ProcessRecoveredSig(p.second);
}

View File

@ -1490,10 +1490,7 @@ void CSigSharesManager::AsyncSign(const CQuorumCPtr& quorum, const uint256& id,
void CSigSharesManager::SignPendingSigShares()
{
std::vector<PendingSignatureData> v;
{
LOCK(cs_pendingSigns);
v = std::move(pendingSigns);
}
WITH_LOCK(cs_pendingSigns, v.swap(pendingSigns));
for (const auto& [pQuorum, id, msgHash] : v) {
auto opt_sigShare = CreateSigShare(pQuorum, id, msgHash);