Skip to content

[BUG] Possible memory leak in cliInitHelp at redis-cli.c #14180

@sfu2

Description

@sfu2

Describe the bug

A possible memory leak in the function cliInitHelp at redis-cli.c

To reproduce

  1. commandTable gets assigned with a heap-allocated ptr. HERE
  2. Branch condition may evaluate to true: if (commandTable->type != REDIS_REPLY_MAP && commandTable->type != REDIS_REPLY_ARRAY). HERE
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions