From 44bcb69ccd78493931a92c9138c4bba3312cec9d Mon Sep 17 00:00:00 2001 From: nelisky Date: Thu, 19 Apr 2012 14:45:40 -0700 Subject: [PATCH 1/2] Fixing leak in resp_hdr_cb Memory is allocated for key and val, and longpoll address, when found, is stored in the header_info and prevented from being freed there. This pointer is stored during pool probing but once that's done it was just being lost. Not so visible but also leaking was the refuse reason string. --- util.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/util.c b/util.c index 6a5dcd84..d59fc162 100644 --- a/util.c +++ b/util.c @@ -30,6 +30,12 @@ # include # include #endif +#ifdef DMALLOC +#include +#include +#include +#endif + #include "miner.h" #include "elist.h" #include "compat.h" @@ -364,10 +370,15 @@ json_t *json_rpc_call(CURL *curl, const char *url, if (probing) { pool->probed = true; /* If X-Long-Polling was found, activate long polling */ - if (hi.lp_path) + if (hi.lp_path) { + if (pool->hdr_path != NULL) + free(pool->hdr_path); pool->hdr_path = hi.lp_path; - else + } else { pool->hdr_path = NULL; + } + } else if (hi.lp_path) { + free(hi.lp_path); } *rolltime = hi.has_rolltime; @@ -410,9 +421,11 @@ json_t *json_rpc_call(CURL *curl, const char *url, goto err_out; } - if (hi.reason) + if (hi.reason) { json_object_set_new(val, "reject-reason", json_string(hi.reason)); - + free(hi.reason); + hi.reason = NULL; + } successful_connect = true; databuf_free(&all_data); curl_slist_free_all(headers); From 17b9baa9dad5ccaaef8fe07dc3df5ebeb453bbc1 Mon Sep 17 00:00:00 2001 From: nelisky Date: Fri, 20 Apr 2012 03:36:42 -0700 Subject: [PATCH 2/2] Removing dmalloc import left behind by mistake --- util.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/util.c b/util.c index d59fc162..5257f5c5 100644 --- a/util.c +++ b/util.c @@ -30,11 +30,6 @@ # include # include #endif -#ifdef DMALLOC -#include -#include -#include -#endif #include "miner.h" #include "elist.h"