JSON RPC: fixed memory leak after an error

This commit is contained in:
SChernykh 2024-08-13 15:06:35 +02:00
parent f3e96d7138
commit bf1a09097f
2 changed files with 5 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -658,7 +658,7 @@ void p2pool::submit_aux_block_async(const std::vector<SubmitAuxBlockData>& 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;
}