From e48dcb7a01cc91aa9d33797da1d1effcbe0cd5ad Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 12 Sep 2019 12:29:47 +0000 Subject: levin: armour against some "should not happen" case If adding a response handler after the protocol is released, they could never be cancelled again, and would end up keeping a ref that never goes away --- contrib/epee/include/net/levin_protocol_handler_async.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'contrib/epee/include') diff --git a/contrib/epee/include/net/levin_protocol_handler_async.h b/contrib/epee/include/net/levin_protocol_handler_async.h index 41f01e9a0..5774c0ba7 100644 --- a/contrib/epee/include/net/levin_protocol_handler_async.h +++ b/contrib/epee/include/net/levin_protocol_handler_async.h @@ -272,6 +272,11 @@ public: bool add_invoke_response_handler(const callback_t &cb, uint64_t timeout, async_protocol_handler& con, int command) { CRITICAL_REGION_LOCAL(m_invoke_response_handlers_lock); + if (m_protocol_released) + { + MERROR("Adding response handler to a released object"); + return false; + } boost::shared_ptr handler(boost::make_shared>(cb, timeout, con, command)); m_invoke_response_handlers.push_back(handler); return handler->is_timer_started(); -- cgit v1.2.3