Skip to content

Conversation

@svc-rdkeportal01
Copy link

@svc-rdkeportal01 svc-rdkeportal01 commented Dec 2, 2025

Fix NULL_RETURNS in checkmd5

Issues Fixed

  • Coverity CID 86: NULL_RETURNS in test/rbus/elementTree.c at line 58

Root Cause

fopen() can return NULL if the file cannot be opened (e.g., permission denied, disk full). The original code uses the file pointer without checking for NULL, then attempts to close it, which can cause a segmentation fault.

Changes Made

Added NULL check before using the file pointer returned by fopen():

Before:

FILE* f = fopen(path, "w");
fprintRegisteredElements(f, root, 0);
fclose(f);

After:

FILE* f = fopen(path, "w");

if(!f) {
    printf("%s: Failed to open file %s\n", __FUNCTION__, path);
    return;
}

fprintRegisteredElements(f, root, 0);
fclose(f);
  • Line: 58

Coverity issue ID: 86 (line 58)
Fix generated by RDKDevPilot AI Bot

Co-authored-by: rdkdevpilot <bot@rdkcentral.com>
@svc-rdkeportal01 svc-rdkeportal01 requested a review from a team as a code owner December 2, 2025 16:38
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.

1 participant