mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-14 08:48:01 +00:00
util.c: Decreasing reference count on allocated JSON obects to prevent memory leak
This commit is contained in:
parent
cd7f6ed56a
commit
8fa5ddfd2c
22
util.c
22
util.c
@ -1736,8 +1736,10 @@ bool parse_method(struct pool *pool, char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
method = json_object_get(val, "method");
|
method = json_object_get(val, "method");
|
||||||
if (!method)
|
if (!method) {
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
err_val = json_object_get(val, "error");
|
err_val = json_object_get(val, "error");
|
||||||
params = json_object_get(val, "params");
|
params = json_object_get(val, "params");
|
||||||
|
|
||||||
@ -1751,42 +1753,51 @@ bool parse_method(struct pool *pool, char *s)
|
|||||||
|
|
||||||
applog(LOG_INFO, "JSON-RPC method decode failed: %s", ss);
|
applog(LOG_INFO, "JSON-RPC method decode failed: %s", ss);
|
||||||
|
|
||||||
|
json_decref(val);
|
||||||
free(ss);
|
free(ss);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = (char *)json_string_value(method);
|
buf = (char *)json_string_value(method);
|
||||||
if (!buf)
|
if (!buf) {
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strncasecmp(buf, "mining.notify", 13)) {
|
if (!strncasecmp(buf, "mining.notify", 13)) {
|
||||||
if (parse_notify(pool, params))
|
if (parse_notify(pool, params))
|
||||||
pool->stratum_notify = ret = true;
|
pool->stratum_notify = ret = true;
|
||||||
else
|
else
|
||||||
pool->stratum_notify = ret = false;
|
pool->stratum_notify = ret = false;
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncasecmp(buf, "mining.set_difficulty", 21) && parse_diff(pool, params)) {
|
if (!strncasecmp(buf, "mining.set_difficulty", 21) && parse_diff(pool, params)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncasecmp(buf, "client.reconnect", 16) && parse_reconnect(pool, params)) {
|
if (!strncasecmp(buf, "client.reconnect", 16) && parse_reconnect(pool, params)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncasecmp(buf, "client.get_version", 18) && send_version(pool, val)) {
|
if (!strncasecmp(buf, "client.get_version", 18) && send_version(pool, val)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strncasecmp(buf, "client.show_message", 19) && show_message(pool, params)) {
|
if (!strncasecmp(buf, "client.show_message", 19) && show_message(pool, params)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1829,13 +1840,16 @@ bool auth_stratum(struct pool *pool)
|
|||||||
applog(LOG_WARNING, "pool %d JSON stratum auth failed: %s", pool->pool_no, ss);
|
applog(LOG_WARNING, "pool %d JSON stratum auth failed: %s", pool->pool_no, ss);
|
||||||
free(ss);
|
free(ss);
|
||||||
|
|
||||||
return ret;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
applog(LOG_INFO, "Stratum authorisation success for pool %d", pool->pool_no);
|
applog(LOG_INFO, "Stratum authorisation success for pool %d", pool->pool_no);
|
||||||
pool->probed = true;
|
pool->probed = true;
|
||||||
successful_connect = true;
|
successful_connect = true;
|
||||||
|
|
||||||
|
out:
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2381,6 +2395,7 @@ out:
|
|||||||
|
|
||||||
applog(LOG_DEBUG, "Failed to resume stratum, trying afresh");
|
applog(LOG_DEBUG, "Failed to resume stratum, trying afresh");
|
||||||
noresume = true;
|
noresume = true;
|
||||||
|
json_decref(val);
|
||||||
goto resend;
|
goto resend;
|
||||||
}
|
}
|
||||||
applog(LOG_DEBUG, "Initiate stratum failed");
|
applog(LOG_DEBUG, "Initiate stratum failed");
|
||||||
@ -2388,6 +2403,7 @@ out:
|
|||||||
suspend_stratum(pool);
|
suspend_stratum(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user