aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-01-25 16:51:50 -0800
committerRiccardo Spagni <ric@spagni.net>2018-01-25 16:51:50 -0800
commit5a15a8322e72e1e5455ef2fb81ff4c12ad82c9a8 (patch)
tree1b8ea655ed977d5680b0b28f359e61ace7c8d132 /src
parentMerge pull request #3126 (diff)
parentp2p: fix picking peers off an empty gray list (diff)
downloadmonero-5a15a8322e72e1e5455ef2fb81ff4c12ad82c9a8.tar.xz
Merge pull request #3153
ab58b150 p2p: fix picking peers off an empty gray list (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/p2p/net_node.inl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 269a9ba87..f8b96d7a4 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -1062,7 +1062,10 @@ namespace nodetool
max_random_index = std::min<uint64_t>(local_peers_count -1, 20);
random_index = get_random_index_with_fixed_probability(max_random_index);
} else {
- random_index = crypto::rand<size_t>() % m_peerlist.get_gray_peers_count();
+ local_peers_count = m_peerlist.get_gray_peers_count();
+ if (!local_peers_count)
+ return false;
+ random_index = crypto::rand<size_t>() % local_peers_count;
}
CHECK_AND_ASSERT_MES(random_index < local_peers_count, false, "random_starter_index < peers_local.size() failed!!");