From 3a08819f5169f9702cde680acb6bf0c75fa70ffb Mon Sep 17 00:00:00 2001 From: LuMingYinDetect <156896793+LuMingYinDetect@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:51:33 +0800 Subject: [PATCH] Fix some memory leaks in redis-cli (#13258) Fix memory leak related to variable slot_nodes in the clusterManagerFixSlotsCoverage() function. --------- Co-authored-by: debing.sun --- src/redis-cli.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/redis-cli.c b/src/redis-cli.c index 6fcb161d7..17a1836d3 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -3694,6 +3694,8 @@ static int evalMode(int argc, char **argv) { /* Call it */ int eval_ldb = config.eval_ldb; /* Save it, may be reverted. */ retval = issueCommand(argc+3-got_comma, argv2); + for (j = 0; j < argc+3-got_comma; j++) sdsfree(argv2[j]); + free(argv2); if (eval_ldb) { if (!config.eval_ldb) { /* If the debugging session ended immediately, there was an @@ -6079,6 +6081,7 @@ static int clusterManagerFixSlotsCoverage(char *all_slots) { if (!clusterManagerCheckRedisReply(n, reply, NULL)) { fixed = -1; if (reply) freeReplyObject(reply); + if (slot_nodes) listRelease(slot_nodes); goto cleanup; } assert(reply->type == REDIS_REPLY_ARRAY);