Fix memory leak.

This commit is contained in:
XMRig 2020-05-05 16:05:50 +07:00
parent dd7789763f
commit 39ae24b138
No known key found for this signature in database
GPG key ID: 446A53638BE94409

View file

@ -128,8 +128,9 @@ void xmrig::HttpClient::read(const char *data, size_t size)
void xmrig::HttpClient::onConnect(uv_connect_t *req, int status) void xmrig::HttpClient::onConnect(uv_connect_t *req, int status)
{ {
auto client = static_cast<HttpClient *>(req->data); auto client = static_cast<HttpClient *>(req->data);
delete req;
if (!client) { if (!client) {
delete req;
return; return;
} }
@ -138,9 +139,7 @@ void xmrig::HttpClient::onConnect(uv_connect_t *req, int status)
LOG_ERR("[%s:%d] connect error: \"%s\"", client->m_dns->host().data(), client->port(), uv_strerror(status)); LOG_ERR("[%s:%d] connect error: \"%s\"", client->m_dns->host().data(), client->port(), uv_strerror(status));
} }
delete req; return client->close(status);
client->close(status);
return;
} }
uv_read_start(client->stream(), NetBuffer::onAlloc, uv_read_start(client->stream(), NetBuffer::onAlloc,