Skip to content

Fix memory allocation error handling by closing file#12

Open
yss-ef wants to merge 2 commits intooracle:masterfrom
yss-ef:yss-ef/fix/Resource-leak
Open

Fix memory allocation error handling by closing file#12
yss-ef wants to merge 2 commits intooracle:masterfrom
yss-ef:yss-ef/fix/Resource-leak

Conversation

@yss-ef
Copy link
Copy Markdown

@yss-ef yss-ef commented Apr 23, 2026

Description

This Pull Request addresses a resource leak identified in issue #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 #2

Signed-off-by: Fellah Youssef

Signed-off-by: Fellah Youssef <fellahyoussef010@gmail.com>
@oracle-contributor-agreement
Copy link
Copy Markdown

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the 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.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Apr 23, 2026
# 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>
@yss-ef yss-ef closed this Apr 23, 2026
@yss-ef yss-ef reopened this Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource leak

1 participant