From b013d2c4dbea97544239deebe7a8f5a19f2b5604 Mon Sep 17 00:00:00 2001 From: artix Date: Wed, 6 Jun 2018 18:45:31 +0200 Subject: [PATCH] Cluster Manager: fix memory leak in clusterManagerWaitForClusterJoin --- src/redis-cli.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 9ff4dfb9..9e246dce 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -3413,11 +3413,12 @@ static void clusterManagerWaitForClusterJoin(void) { sleep(1); if (++counter > check_after) { dict *status = clusterManagerGetLinkStatus(); + dictIterator *iter = NULL; if (status != NULL && dictSize(status) > 0) { printf("\n"); clusterManagerLogErr("Warning: %d node(s) may " "be unreachable\n", dictSize(status)); - dictIterator *iter = dictGetIterator(status); + iter = dictGetIterator(status); dictEntry *entry; while ((entry = dictNext(iter)) != NULL) { sds nodeaddr = (sds) dictGetKey(entry); @@ -3447,11 +3448,11 @@ static void clusterManagerWaitForClusterJoin(void) { "from standard instance port.\n"); listEmpty(from); } - dictReleaseIterator(iter); - dictRelease(status); } + if (iter != NULL) dictReleaseIterator(iter); + if (status != NULL) dictRelease(status); counter = 0; - } + } } printf("\n"); }