diff options
author | SChernykh <sergey.v.chernykh@gmail.com> | 2020-12-08 18:27:19 +0100 |
---|---|---|
committer | SChernykh <sergey.v.chernykh@gmail.com> | 2020-12-08 18:43:44 +0100 |
commit | c0c75ac19d77a542abacd27796364c6518f7ae59 (patch) | |
tree | 0c14970ec93dd12072549cece25f150c1a660d37 /src/p2p | |
parent | Merge pull request #7072 (diff) | |
download | monero-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.inl | 8 |
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> |