net: Ensure CNode.cleanSubVer is always assigned before nVersion

This commit is contained in:
Luke Dashjr 2022-11-04 21:25:51 +00:00
parent c2a21c0670
commit df874f848a

View File

@ -3224,6 +3224,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// Change version
const int greatest_common_version = std::min(nVersion, PROTOCOL_VERSION);
pfrom.SetCommonVersion(greatest_common_version);
{
LOCK(pfrom.m_subver_mutex);
pfrom.cleanSubVer = cleanSubVer;
}
pfrom.nVersion = nVersion;
const CNetMsgMaker msg_maker(greatest_common_version);
@ -3246,10 +3250,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
pfrom.m_has_all_wanted_services = HasAllDesirableServiceFlags(nServices);
peer->m_their_services = nServices;
pfrom.SetAddrLocal(addrMe);
{
LOCK(pfrom.m_subver_mutex);
pfrom.cleanSubVer = cleanSubVer;
}
peer->m_starting_height = starting_height;
// We only initialize the m_tx_relay data structure if: