rbuscli: fixup potential memory leak#384
Open
Permanence-AI-Coder wants to merge 1 commit intordkcentral:developfrom
Open
rbuscli: fixup potential memory leak#384Permanence-AI-Coder wants to merge 1 commit intordkcentral:developfrom
Permanence-AI-Coder wants to merge 1 commit intordkcentral:developfrom
Conversation
The changes in this PR were automatically generated by the Permanence AI Coder and reviewed by @dnovick and @jweese. There is a corner case where, if `rbus_discoverComponentName` succeeds, but the returned component count is 0, `pComponentNames` will not be freed. This change moves the free of `pComponentNames` to the bottom of the function so it will always be executed. `pComponentNames` is initialized to NULL, so it is safe to free it even if no allocation occurs. on-behalf-of: @permanence-ai github-ai@permanence.ai
karuna2git
requested changes
Dec 1, 2025
| printf ("Failed to discover components. Error Code = %d\r\n", rc); | ||
| } | ||
|
|
||
| free(pComponentNames); |
Contributor
There was a problem hiding this comment.
Could lead to crash when discovery is failed.. so null pointer check is necessary here.
Where as in the original code, it is freed only when discovery is success and it has valid count.
There was a problem hiding this comment.
If I understand correctly, if discovery fails, no allocation is done, so the value is still NULL from the initialization in L970, and free(NULL) is a safe operation.
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.
The changes in this PR were automatically generated by the Permanence AI Coder and reviewed by @dnovick and @jweese. There is a corner case where, if
rbus_discoverComponentNamesucceeds, but the returned component count is 0,pComponentNameswill not be freed. This change moves the free ofpComponentNamesto the bottom of the function so it will always be executed.pComponentNamesis initialized to NULL, so it is safe to free it even if no allocation occurs.This PR complies with RDK LLM usage requirements.
on-behalf-of: @permanence-ai github-ai@permanence.ai