From d8b023350fa62b9068dcc5c56c21fc9256a31f5d Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 30 May 2014 09:07:48 +1000 Subject: [PATCH] Don't remove the ram from dead client instances to prevent a dereference --- src/stratifier.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 1c6a127d..a946c6f9 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -232,6 +232,7 @@ typedef struct stratum_instance stratum_instance_t; * is sorted by enonce1_64. */ static stratum_instance_t *stratum_instances; static stratum_instance_t *disconnected_instances; +static stratum_instance_t *dead_instances; /* Protects both stratum and user instances */ static cklock_t instance_lock; @@ -782,11 +783,8 @@ static void drop_client(int id) if (!old_client) { stats.reusable_clients++; HASH_ADD(hh, disconnected_instances, enonce1_64, sizeof(uint64_t), client); - } else { - dealloc(client->workername); - dealloc(client->useragent); - free(client); - } + } else // Keep around instance so we don't get a dereference + HASH_ADD(hh, dead_instances, enonce1_64, sizeof(uint64_t), client); ck_dwilock(&instance_lock); } ck_uilock(&instance_lock);