std::map::at
returns a reference to the value, not an iterator on the map, which is what is required here for the i->second
call below. Alternatively:
0diff --git a/src/net.cpp b/src/net.cpp
1index 9c2a79b809..e6a3d69810 100644
2--- a/src/net.cpp
3+++ b/src/net.cpp
4@@ -670,11 +670,11 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
5
6 //store received bytes per message command
7 //to prevent a memory DOS, only allow valid commands
8- mapMsgCmdSize::iterator i = mapRecvBytesPerMsgCmd.find(msg.m_command);
9- if (i == mapRecvBytesPerMsgCmd.end())
10- i = mapRecvBytesPerMsgCmd.find(NET_MESSAGE_COMMAND_OTHER);
11- assert(i != mapRecvBytesPerMsgCmd.end());
12- i->second += msg.m_raw_message_size;
13+ if (auto i = mapRecvBytesPerMsgCmd.find(msg.m_command); i != mapRecvBytesPerMsgCmd.end()) {
14+ i->second += msg.m_raw_message_size;
15+ } else {
16+ mapRecvBytesPerMsgCmd.at(NET_MESSAGE_COMMAND_OTHER) += msg.m_raw_message_size;
17+ }