Fix memory allocation error handling by closing file#12
Open
yss-ef wants to merge 2 commits intooracle:masterfrom
Open
Fix memory allocation error handling by closing file#12yss-ef wants to merge 2 commits intooracle:masterfrom
yss-ef wants to merge 2 commits intooracle:masterfrom
Conversation
Signed-off-by: Fellah Youssef <fellahyoussef010@gmail.com>
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
# Description This Pull Request addresses a resource leak identified in issue **oracle#2**. In `fdr/fdrd.c`, a file stream is opened using `fopen()` at line 572 to read configuration data. However, the function returns early at line 581 without invoking `fclose()`, leaving the file descriptor open. This PR ensures that `fclose(f)` is called before the return statement to properly release the system resource. ## Changes * **fdr/fdrd.c**: Added `fclose(f)` call prior to the error/exit return path at line 581. ## Validation * **Static Analysis**: Verified that the logic flow now reaches a `fclose()` call for every successful `fopen()`. * **Build**: Confirmed the project compiles without warnings on **Fedora 43**. * **Manual Test**: Ran the daemon and monitored open file descriptors using `lsof -p [pid]` to ensure descriptors are correctly released after parsing. --- **Fixes oracle#2** Signed-off-by: Fellah Youssef <your-email@example.com> Signed-off-by: Fellah Youssef <fellahyoussef010@gmail.com>
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.
Description
This Pull Request addresses a resource leak identified in issue #2.
In
fdr/fdrd.c, a file stream is opened usingfopen()at line 572 to read configuration data. However, the function returns early at line 581 without invokingfclose(), leaving the file descriptor open. This PR ensures thatfclose(f)is called before the return statement to properly release the system resource.Changes
fclose(f)call prior to the error/exit return path at line 581.Validation
fclose()call for every successfulfopen().lsof -p [pid]to ensure descriptors are correctly released after parsing.Fixes #2
Signed-off-by: Fellah Youssef