From 64324901f22946a93226e0af56a6e59b2290be09 Mon Sep 17 00:00:00 2001 From: yongman Date: Fri, 16 Nov 2018 17:20:53 +0800 Subject: [PATCH] Fix pointer access and memory leak in redis-cli. --- src/redis-cli.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 1aa6751f..4f68be20 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -2829,7 +2829,7 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source, if (err != NULL) { *err = zmalloc((reply->len + 1) * sizeof(char)); strcpy(*err, reply->str); - CLUSTER_MANAGER_PRINT_REPLY_ERROR(source, err); + CLUSTER_MANAGER_PRINT_REPLY_ERROR(source, *err); } goto next; } @@ -2947,7 +2947,7 @@ static int clusterManagerMoveSlot(clusterManagerNode *source, if (err != NULL) { *err = zmalloc((r->len + 1) * sizeof(char)); strcpy(*err, r->str); - CLUSTER_MANAGER_PRINT_REPLY_ERROR(n, err); + CLUSTER_MANAGER_PRINT_REPLY_ERROR(n, *err); } } freeReplyObject(r); @@ -5196,10 +5196,13 @@ static int clusterManagerCommandSetTimeout(int argc, char **argv) { n->port); ok_count++; continue; -reply_err: +reply_err:; + int need_free = 0; if (err == NULL) err = ""; + else need_free = 1; clusterManagerLogErr("ERR setting node-timeot for %s:%d: %s\n", n->ip, n->port, err); + if (need_free) zfree(err); err_count++; } clusterManagerLogInfo(">>> New node timeout set. %d OK, %d ERR.\n",