Skip to content

Conversation

@svc-rdkeportal01
Copy link

@svc-rdkeportal01 svc-rdkeportal01 commented Nov 29, 2025

Fix Coverity RESOURCE_LEAK in testSerialize

In the original code, rbusBuffer_Create() allocates memory for buffOut (line 51) and buffIn (line 62). When the second fopen() call fails at line 64, the function returns at line 67 without freeing these allocated buffers, causing a resource leak.

This change adds explicit rbusBuffer_Destroy() calls for both buffOut and buffIn before the early return, matching the cleanup pattern used at the end of the function (lines 90-91). All other behavior is unaffected.

Coverity Defect: Line 67 in test/rbus/consumer/filter.c, function testSerialize()
Coverity Issue ID: 109 (from Confluence wiki)

- Coverity issue ID: 109 (line 67)
- Fix generated by RDKDevPilot AI Bot
- Add cleanup for buffOut and buffIn before early return
@svc-rdkeportal01 svc-rdkeportal01 requested a review from a team as a code owner November 29, 2025 17:50
Copilot AI review requested due to automatic review settings November 29, 2025 17:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a Coverity-reported resource leak in the testSerialize() function in test/rbus/consumer/filter.c. When the second fopen() call fails, the function was returning early without freeing the previously allocated buffOut and buffIn buffers, causing a memory leak.

  • Adds explicit cleanup calls for buffOut and buffIn before the early return on line 70
  • Includes a clarifying comment explaining the purpose of the cleanup
  • Follows the existing cleanup pattern used at the end of the function (lines 93-94)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants