redis / redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.

Home Page:http://redis.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]There is a memory leak defect at line 3615 in the file /redis/src/redis-cli.c.

LuMingYinDetect opened this issue · comments

Describe the bug

At line 3540 in the file /redis/src/redis-cli.c, a pointer variable named argv2 is defined. This pointer variable is assigned a dynamically allocated memory block using the zmalloc function at line 3580. The program uses this pointer in the issueCommand function at line 3595. When the program returns at line 3615, the dynamically allocated memory pointed to by argv2 is not freed, leading to a memory leak defect, as illustrated in the diagram below:
https://github.com/LuMingYinDetect/redis_defects/blob/main/redis_2.png

To reproduce

The detection tool I'm using is the Clang Static Analyzer, which employs static analysis techniques. The tool's defect reports provide the path that triggers the defect. Based on the aforementioned path, the defect can be reproduced.

Expected behavior

If the defect is confirmed, it is advisable to address it by making necessary fixes.

@LuMingYinDetect thanks, let's fix it in #13258 together.

@LuMingYinDetect thanks, let's fix it in #13258 together.

Thank you for your prompt response! I have fixed the issue and synced it to the pull request.