Skip to content

[SAST] Fix multiple memory leaks - #2761

Open
Canned-pineapple-8 wants to merge 5 commits into
unbit:masterfrom
Canned-pineapple-8:fix/memory-leaks-issue-2760
Open

[SAST] Fix multiple memory leaks#2761
Canned-pineapple-8 wants to merge 5 commits into
unbit:masterfrom
Canned-pineapple-8:fix/memory-leaks-issue-2760

Conversation

@Canned-pineapple-8

Copy link
Copy Markdown

Fixes 5 memory leaks found by Svace static analyzer.

If any fix is incorrect, please comment on the specific commit or reference the problem number from issue #2760. I will update the PR accordingly.

Closes #2760

Variable 'bie' is heap-allocated when isize > sizeof(struct inotify_event).
If read() fails, the function returns NULL without freeing bie.

This commit adds a conditional free() before the return.

Fixes memory leak found by Svace static analyzer
Variable 'id' allocated in uwsgi_attach_fd() is not freed
in several code paths. Add a cleanup block and use
goto to ensure id is released.

Fixes memory leak found by Svace static analyzer
Pointers 'secret' and 'iv' are conditionally heap-allocated
when cipher_len > s_len or iv_len > s_iv_len respectively.
At the successful return path (line 1154) they are never freed.

This commit adds two conditional free() calls before returning ul.

Fixes memory leak found by Svace static analyzer
Variable 'plugin_entry_symbol' is dynamically allocated but not freed
if both dlsym() calls fail. Free it appropriately.

Fixes memory leak found by Svace static analyzer
In parse_sys_envs(), earg is malloc()'ed. If strchr() fails to find '=', the loop breaks without freeing earg.

Add free(earg) before break.

Fixes memory leak found by Svace static analyzer
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

Successfully merging this pull request may close these issues.

[SAST] Several potential memory leaks

1 participant