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:
diff --git a/src/net.cpp b/src/net.cpp
index 9c2a79b809..e6a3d69810 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -670,11 +670,11 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
//store received bytes per message command
//to prevent a memory DOS, only allow valid commands
- mapMsgCmdSize::iterator i = mapRecvBytesPerMsgCmd.find(msg.m_command);
- if (i == mapRecvBytesPerMsgCmd.end())
- i = mapRecvBytesPerMsgCmd.find(NET_MESSAGE_COMMAND_OTHER);
- assert(i != mapRecvBytesPerMsgCmd.end());
- i->second += msg.m_raw_message_size;
+ if (auto i = mapRecvBytesPerMsgCmd.find(msg.m_command); i != mapRecvBytesPerMsgCmd.end()) {
+ i->second += msg.m_raw_message_size;
+ } else {
+ mapRecvBytesPerMsgCmd.at(NET_MESSAGE_COMMAND_OTHER) += msg.m_raw_message_size;
+ }