Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a memory leak defect at line 3466 in the file /zstd/lib/compress/zstd_compress.c. #4112

Open
LuMingYinDetect opened this issue Aug 6, 2024 · 0 comments

Comments

@LuMingYinDetect
Copy link

A pointer variable named dst is defined at line 3461 in the file /zstd/lib/compress/zstd_compress.c and a new dynamic memory area is allocated to it using the function ZSTD_customMalloc. If the RETURN_ERROR_IF macro condition at line 3466 is met, the function will return at this line, and the release operation of the dynamic memory area pointed to by dst at line 3484 will not be executed, resulting in a memory leak, as shown in the figure below:
https://github.com/LuMingYinDetect/zstd_defects/blob/main/zstd_1.png

Adenilson pushed a commit to Adenilson/zstd that referenced this issue Aug 7, 2024
Sanity checks on a few of the context parameters (i.e. workers and block size)
may prompt an early return on ZSTD_generateSequences.

Allocating the destination buffer past those return points avoids a potential
memory leak.

This patch should fix issue facebook#4112.
Adenilson pushed a commit to Adenilson/zstd that referenced this issue Aug 7, 2024
Sanity checks on a few of the context parameters (i.e. workers and block size)
may prompt an early return on ZSTD_generateSequences.

Allocating the destination buffer past those return points avoids a potential
memory leak.

This patch should fix issue facebook#4112.
Adenilson pushed a commit to Adenilson/zstd that referenced this issue Aug 7, 2024
Sanity checks on a few of the context parameters (i.e. workers and block size)
may prompt an early return on ZSTD_generateSequences.

Allocating the destination buffer past those return points avoids a potential
memory leak.

This patch should fix issue facebook#4112.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant