fix: ensure variables are initialized before goto

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.
pull/553/head
Alexander Shirokov 2 months ago
parent 3a1480e594
commit 5f5919d879
No known key found for this signature in database
GPG Key ID: 6020E4D7AFA8ECE7

@ -973,6 +973,9 @@ IedConnection_setGoCBValuesAsync(IedConnection self, IedClientError* error, Clie
char domainId[65];
char itemId[130];
LinkedList itemIds = NULL;
LinkedList values = NULL;
if (MmsMapping_getMmsDomainFromObjectReference(goCB->objectReference, domainId) == NULL)
{
*error = IED_ERROR_OBJECT_REFERENCE_INVALID;;
@ -1006,8 +1009,8 @@ IedConnection_setGoCBValuesAsync(IedConnection self, IedClientError* error, Clie
int itemIdLen = strlen(itemId);
/* create the list of requested itemIds references */
LinkedList itemIds = LinkedList_create();
LinkedList values = LinkedList_create();
itemIds = LinkedList_create();
values = LinkedList_create();
/* add rGoEna as last element */
if (parametersMask & GOCB_ELEMENT_GO_ID)

@ -223,6 +223,10 @@ exit_error:
IedModel*
ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
{
IedModel* model = NULL;
int indendation = 0;
int currentLine = 0;
uint8_t* lineBuffer = (uint8_t*)GLOBAL_MALLOC(READ_BUFFER_MAX_SIZE);
if (lineBuffer == NULL)
@ -231,11 +235,9 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
int bytesRead = 1;
bool stateInModel = false;
int indendation = 0;
bool inArray = false;
bool inArrayElement = false;
IedModel* model = NULL;
LogicalDevice* currentLD = NULL;
LogicalNode* currentLN = NULL;
ModelNode* currentModelNode = NULL;
@ -248,7 +250,6 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
char nameString2[130];
char nameString3[130];
int currentLine = 0;
while (bytesRead > 0)
{

Loading…
Cancel
Save