[SAST] Fix multiple memory leaks - #2761
Open
Canned-pineapple-8 wants to merge 5 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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