mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-08-20 05:28:47 -06:00
JSONRPCRequest: fixed undefined behavior in the error handler
This commit is contained in:
parent
5dd8d11b72
commit
07cfb54bdc
@ -36,10 +36,11 @@ public:
|
|||||||
static FORCEINLINE void call(const char* address, int port, const char* req, T&& cb, U&& close_cb)
|
static FORCEINLINE void call(const char* address, int port, const char* req, T&& cb, U&& close_cb)
|
||||||
{
|
{
|
||||||
// It will be deleted in one of the tcp callbacks eventually
|
// It will be deleted in one of the tcp callbacks eventually
|
||||||
JSONRPCRequest* r = new JSONRPCRequest(address, port, req, new Callback<T>(std::move(cb)), new Callback<U>(std::move(close_cb)));
|
CallbackBase* close_callback = new Callback<U>(std::move(close_cb));
|
||||||
|
JSONRPCRequest* r = new JSONRPCRequest(address, port, req, new Callback<T>(std::move(cb)), close_callback);
|
||||||
if (!r->m_valid) {
|
if (!r->m_valid) {
|
||||||
constexpr char err[] = "internal error";
|
constexpr char err[] = "internal error";
|
||||||
close_cb(err, sizeof(err) - 1);
|
(*close_callback)(err, sizeof(err) - 1);
|
||||||
delete r;
|
delete r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user