Skip to content

RDKCOM-5676: RDKBDEV-3524 Fix file resource leak in readFileToBuffer() - #1454

Open
Yashu37 wants to merge 1 commit into
rdkcentral:developfrom
Yashu37:RDKBDEV-3524-resource-leak
Open

Yashu37 wants to merge 1 commit into
rdkcentral:developfrom
Yashu37:RDKBDEV-3524-resource-leak

Conversation

@Yashu37

@Yashu37 Yashu37 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Issue:
readFileToBuffer() opens the file using fopen(), but the file handle is not closed with fclose() on the successful return path, causing a file resource leak.

Steps to Reproduce:

  1. Invoke readFileToBuffer() with a valid file.
  2. Observe the successful execution path.
  3. Check the opened file handle after the function returns.

Expected Behaviour:
The opened file should be properly closed before the function returns.

Fix:
Add fclose(infile) before the successful return.

Acceptance Criteria:
1.infile is closed using fclose() before returning.
2.No file resource leak is observed.
3.Existing functionality remains unchanged.

Copilot AI lite review requested due to automatic review settings September 23, 2026 08:27
@Yashu37
Yashu37 requested a review from a team as a code owner September 23, 2026 08:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The file handle is now closed on the successful path, with no unresolved issues.

Review effort: Lite
Findings: None

What changed in this PR

Fixes a file resource leak in readFileToBuffer() by closing the opened file on successful reads.

Changes:

  • Adds fclose(infile) before the successful return.
  • Prevents leaked file handles without changing existing behavior.
File Summary
source/​core/​wifi_passpoint.c Closes the file handle on successful reads.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pradeeptakdas pradeeptakdas changed the title RDKBDEV-3524: Fix file resource leak in readFileToBuffer() RDKCOM-5676: RDKBDEV-3524 Fix file resource leak in readFileToBuffer() Sep 28, 2026
@AkhilaReddyK7 AkhilaReddyK7 added the community contribution Contributions from community. label Sep 28, 2026
Problem:
    readFileToBuffer() does not close the file handle on the successful return path, causing a file resource leak.

Fix:
    Added fclose(infile) before the successful return to properly release the file resource.

Signed-off-by: Yashodha KB <yakshagowda37@gmail.com>
@tinaelizabeth84
tinaelizabeth84 force-pushed the RDKBDEV-3524-resource-leak branch from 47fa560 to 23e66e9 Compare October 1, 2026 13:37
Copilot AI lite review requested due to automatic review settings October 1, 2026 13:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The successful path now closes the file handle while preserving existing behavior.

Review effort: Lite
Findings: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community contribution Contributions from community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants