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 /contrib/epee/include/net/levin_protocol_handler.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 'contrib/epee/include/net/levin_protocol_handler.h')
-rw-r--r-- | contrib/epee/include/net/levin_protocol_handler.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/contrib/epee/include/net/levin_protocol_handler.h b/contrib/epee/include/net/levin_protocol_handler.h index fbc9727e2..b3a75bedc 100644 --- a/contrib/epee/include/net/levin_protocol_handler.h +++ b/contrib/epee/include/net/levin_protocol_handler.h @@ -43,6 +43,8 @@ namespace levin struct protocl_handler_config { levin_commands_handler<t_connection_context>* m_pcommands_handler; + void (*m_pcommands_handler_destroy)(levin_commands_handler<t_connection_context>*); + ~protocl_handler_config() { if (m_pcommands_handler && m_pcommands_handler_destroy) (*m_pcommands_handler_destroy)(m_pcommands_handler); } }; template<class t_connection_context = net_utils::connection_context_base> |