Skip to content

Conversation

@alexs-sh
Copy link

Hello,

This commit adds variable initialization before goto statement can be executed. As a result, it prevents jumping to code that uses uninitialized variables.

Here is an example from IedConnection_setGoCBValuesAsync at client_goose_control.c

    if (separator == NULL)
    {
        *error = IED_ERROR_OBJECT_REFERENCE_INVALID;
        goto exit_function;
    }
...
   
    /* create the list of requested itemIds references */
    LinkedList itemIds = LinkedList_create();
    LinkedList values = LinkedList_create();

...
exit_function:
    LinkedList_destroy(itemIds);
    LinkedList_destroyStatic(values);

If separator is NULL, a goto exit_function is triggered. However, exit_function uses itemIds and values, which may be uninitialized since they are assigned after the goto.

This is a rare but possible issue, detectable with Clang and -Wsometimes-uninitialized flag.

Please let me know if any additional information, testing, or clarification is needed.

Thank you

This commit adds variable initialization before any goto statement can be
executed. As a result, it prevents jumping to code that uses uninitialized
variables.

This is a rare but possible issue, detectable with Clang and
-Wsometimes-uninitialized flag.
@sonarqubecloud
Copy link

mzillgith added a commit that referenced this pull request Jul 31, 2025
- fixed problem in handling of memory allocation error (#553)
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