From d385b74b6fec45bca2d95f33c512f2827a8d90fc Mon Sep 17 00:00:00 2001 From: ckolivas Date: Sun, 4 Aug 2024 09:48:14 +1000 Subject: [PATCH] Fix potential memleak of shares in ckproxy generator code. --- src/generator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/generator.c b/src/generator.c index 9768d507..41767f5c 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1772,8 +1772,10 @@ static int parse_share(gdata_t *gdata, proxy_instance_t *proxi, const char *buf) mutex_lock(&gdata->share_lock); HASH_FIND_I64(gdata->shares, &id, share); - if (share) + if (share) { HASH_DEL(gdata->shares, share); + free(share); + } mutex_unlock(&gdata->share_lock); if (!share) { @@ -2401,6 +2403,7 @@ static void *proxy_recv(void *arg) HASH_ITER(hh, gdata->shares, share, tmpshare) { if (share->submit_time < now - 120) { HASH_DEL(gdata->shares, share); + free(share); } } mutex_unlock(&gdata->share_lock); @@ -2543,6 +2546,7 @@ static void *userproxy_recv(void *arg) HASH_ITER(hh, gdata->shares, share, tmpshare) { if (share->submit_time < now - 120) { HASH_DEL(gdata->shares, share); + free(share); } } mutex_unlock(&gdata->share_lock);