diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-10-09 16:46:42 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-10-09 16:46:42 +0100 |
commit | 7dbf76d0da5c78b8e987ce3fe1bf25781b02b82e (patch) | |
tree | 831f55935dba7a8c88fb2e0abc9c350c7184a215 /tests/net_load_tests/net_load_tests.h | |
parent | Merge pull request #2548 (diff) | |
download | monero-7dbf76d0da5c78b8e987ce3fe1bf25781b02b82e.tar.xz |
Fix an object lifetime bug in net load tests
The commands handler must not be destroyed before the config
object, or we'll be accessing freed memory.
An earlier attempt at using boost::shared_ptr to control object
lifetime turned out to be very invasive, though would be a
better solution in theory.
Diffstat (limited to 'tests/net_load_tests/net_load_tests.h')
-rw-r--r-- | tests/net_load_tests/net_load_tests.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/net_load_tests/net_load_tests.h b/tests/net_load_tests/net_load_tests.h index f74282683..ce9d8b6fe 100644 --- a/tests/net_load_tests/net_load_tests.h +++ b/tests/net_load_tests/net_load_tests.h @@ -151,6 +151,11 @@ namespace net_load_tests bool handle_new_connection(const boost::uuids::uuid& connection_id, bool ignore_close_fails = false) { size_t idx = m_next_opened_conn_idx.fetch_add(1, std::memory_order_relaxed); + if (idx >= m_connections.size()) + { + LOG_PRINT_L0("ERROR: connections overflow"); + exit(1); + } m_connections[idx] = connection_id; size_t prev_connection_count = m_opened_connection_count.fetch_add(1, std::memory_order_relaxed); |