rbus: fix coverity RESOURCE_LEAK in testSerialize#394
Open
svc-rdkeportal01 wants to merge 1 commit intodevelopfrom
Open
rbus: fix coverity RESOURCE_LEAK in testSerialize#394svc-rdkeportal01 wants to merge 1 commit intodevelopfrom
svc-rdkeportal01 wants to merge 1 commit intodevelopfrom
Conversation
- Coverity issue ID: 109 (line 67) - Fix generated by RDKDevPilot AI Bot - Add cleanup for buffOut and buffIn before early return
Contributor
There was a problem hiding this comment.
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
buffOutandbuffInbefore 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.
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.
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, functiontestSerialize()Coverity Issue ID: 109 (from Confluence wiki)