Skip to content

Conversation

Copy link

Copilot AI commented Nov 29, 2025

Addresses code review feedback on PR fixing Coverity RESOURCE_LEAK defects. The NULL checks added in the error paths were unnecessary and inconsistent with the rest of the codebase.

Changes

  • Removed redundant NULL checks before free() calls in three discovery functions:
    • execute_discover_component_cmd() (line 1003)
    • execute_discover_elements_cmd() (line 1050)
    • execute_discover_wildcard_dests_cmd() (line 1096)

The C standard guarantees free(NULL) is safe, and the rest of rbuscli.c calls free() directly without NULL checks (lines 953, 955, 991, 993, 1041, 1043, 1090, 1092).

Before:

if (pComponentNames != NULL)
{
    free(pComponentNames);
}

After:

free(pComponentNames);

This reduces code from 5 lines to 1 line per cleanup block while maintaining the same safety guarantees.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix Coverity resource leak in discovery commands Remove unnecessary NULL checks before free() in rbuscli discovery commands Nov 29, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants