Describe the bug
A possible memory leak in the function cliInitHelp
at redis-cli.c
To reproduce
commandTable
gets assigned with a heap-allocated ptr. HERE- Branch condition may evaluate to true:
if (commandTable->type != REDIS_REPLY_MAP && commandTable->type != REDIS_REPLY_ARRAY)
. HERE - Function returns without calling
freeReplyObject(commandTable);
, as the other branchs did.
Expected behavior
The heap-allocated pointer commandTable
should be freed when going out of scope.
Additional information
In the long call chain of redisCommand
, when the reply object gets returned, the original ptr gets assigned to NULL here, making the returned ptr the only reference to the reply object.
Comment From: sundb
@sfu2 thx, do you wanna make a PR to fix it?
Comment From: sfu2
Sure, the fix should be simple enough.