Fix memleak issues in redis-cli (#14186)

This commit is contained in:
Henry 2025-07-11 22:20:00 +08:00 committed by GitHub
parent b8382f0540
commit ebf19e4c92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -453,7 +453,11 @@ static void cliLegacyIntegrateHelp(void) {
if (cliConnect(CC_QUIET) == REDIS_ERR) return;
redisReply *reply = redisCommand(context, "COMMAND");
if(reply == NULL || reply->type != REDIS_REPLY_ARRAY) return;
if (reply == NULL) return;
if (reply->type != REDIS_REPLY_ARRAY) {
freeReplyObject(reply);
return;
}
/* Scan the array reported by COMMAND and fill only the entries that
* don't already match what we have. */
@ -943,7 +947,10 @@ static void cliInitHelp(void) {
cliLegacyIntegrateHelp();
return;
};
if (commandTable->type != REDIS_REPLY_MAP && commandTable->type != REDIS_REPLY_ARRAY) return;
if (commandTable->type != REDIS_REPLY_MAP && commandTable->type != REDIS_REPLY_ARRAY) {
freeReplyObject(commandTable);
return;
}
/* Scan the array reported by COMMAND DOCS and fill in the entries */
helpEntriesLen = cliCountCommands(commandTable);