From bf1a09097f8458aa41b52527874d9d7365f748c8 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:06:35 +0200 Subject: [PATCH] JSON RPC: fixed memory leak after an error --- src/json_rpc_request.cpp | 4 ++++ src/p2pool.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/json_rpc_request.cpp b/src/json_rpc_request.cpp index e05e88a..6fb062e 100644 --- a/src/json_rpc_request.cpp +++ b/src/json_rpc_request.cpp @@ -495,6 +495,8 @@ void Call(const std::string& address, int port, const std::string& req, const st catch (const std::exception& e) { const char* msg = e.what(); (*close_cb)(msg, strlen(msg), 0.0); + delete cb; + delete close_cb; } }); @@ -502,6 +504,8 @@ void Call(const std::string& address, int port, const std::string& req, const st static constexpr char err[] = "CallOnLoop failed"; LOGERR(1, err); (*close_cb)(err, sizeof(err) - 1, 0.0); + delete cb; + delete close_cb; } } diff --git a/src/p2pool.cpp b/src/p2pool.cpp index 4809d21..4cac425 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -658,7 +658,7 @@ void p2pool::submit_aux_block_async(const std::vector& aux_b // If p2pool is stopped, m_submitAuxBlockAsync is most likely already closed if (m_stopped) { - LOGWARN(0, "p2pool is shutting down, but a block was found. Trying to submit it anyway!"); + LOGWARN(0, "p2pool is shutting down, but an aux block was found. Trying to submit it anyway!"); submit_aux_block(); return; }