Fix: possible use after free on shutdown

Console commands could access destroyed objects
This commit is contained in:
SChernykh 2022-09-08 16:16:00 +02:00
parent 3dcd3dbb7f
commit f813cf6d36
2 changed files with 3 additions and 2 deletions

View file

@ -190,7 +190,6 @@ p2pool::~p2pool()
delete m_blockTemplate; delete m_blockTemplate;
delete m_mempool; delete m_mempool;
delete m_params; delete m_params;
delete m_consoleCommands;
} }
bool p2pool::calculate_hash(const void* data, size_t size, uint64_t height, const hash& seed, hash& result) bool p2pool::calculate_hash(const void* data, size_t size, uint64_t height, const hash& seed, hash& result)
@ -471,6 +470,8 @@ void p2pool::on_stop(uv_async_t* async)
{ {
p2pool* pool = reinterpret_cast<p2pool*>(async->data); p2pool* pool = reinterpret_cast<p2pool*>(async->data);
delete pool->m_consoleCommands;
if (pool->m_api) { if (pool->m_api) {
pool->m_api->on_stop(); pool->m_api->on_stop();
} }

View file

@ -36,7 +36,7 @@ public:
bool connect_to_peer(bool is_v6, const char* ip, int port); bool connect_to_peer(bool is_v6, const char* ip, int port);
void drop_connections_async() { uv_async_send(&m_dropConnectionsAsync); } void drop_connections_async() { if (m_finished.load() == 0) { uv_async_send(&m_dropConnectionsAsync); } }
void shutdown_tcp(); void shutdown_tcp();
virtual void print_status(); virtual void print_status();