aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authorSChernykh <sergey.v.chernykh@gmail.com>2020-12-08 18:27:19 +0100
committerSChernykh <sergey.v.chernykh@gmail.com>2020-12-08 18:43:44 +0100
commitc0c75ac19d77a542abacd27796364c6518f7ae59 (patch)
tree0c14970ec93dd12072549cece25f150c1a660d37 /src/p2p
parentMerge pull request #7072 (diff)
downloadmonero-c0c75ac19d77a542abacd27796364c6518f7ae59.tar.xz
Fixed issues found by static analysis
- rolling_median: tried to free uninitialized pointer in a constructor - net_node.inl: erase-remove idiom was used incorrectly. remove_if doesn't actually remove elements, see http://cpp.sh/6fcjv - bulletproofs.cc: call to sizeof() instead of vector.size(), luckily it only impacts performance and not code logic there
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.inl8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 8000835c4..e35a4ccba 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -2830,8 +2830,8 @@ namespace nodetool
const uint32_t index = stripe - 1;
CRITICAL_REGION_LOCAL(m_used_stripe_peers_mutex);
MINFO("adding stripe " << stripe << " peer: " << context.m_remote_address.str());
- std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
- [&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; });
+ m_used_stripe_peers[index].erase(std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
+ [&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; }), m_used_stripe_peers[index].end());
m_used_stripe_peers[index].push_back(context.m_remote_address);
}
@@ -2844,8 +2844,8 @@ namespace nodetool
const uint32_t index = stripe - 1;
CRITICAL_REGION_LOCAL(m_used_stripe_peers_mutex);
MINFO("removing stripe " << stripe << " peer: " << context.m_remote_address.str());
- std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
- [&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; });
+ m_used_stripe_peers[index].erase(std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
+ [&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; }), m_used_stripe_peers[index].end());
}
template<class t_payload_net_handler>