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
+4
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;
}
}