- detect empty array size for globals and initialize as pointer

This commit is contained in:
2017-03-15 12:54:07 +00:00
parent 26f5a868e8
commit 6291fa4b78

View File

@@ -642,7 +642,23 @@ STATIC int8_t cfile_parser_evaluateExpression(char *aExpression, cfile_t *aCfile
// contains array information if available "[10]"
if (XREGEX_IS_MATCHGROUP(matchGroup, 3))
{
xmallocStrlcpy(&variable->array, &aExpression[matchGroup[3].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 3));
xmallocStrlcpy(&tempChar, &aExpression[matchGroup[3].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 3));
if (NULL != tempChar)
{
xStringTrim(tempChar, strlen(tempChar));
}
if (2 == strlen(tempChar))
{
// array without size definition
xmallocStrlcat(&variable->dataType, "*", 1);
}
else
{
xmallocStrlcpy(&variable->array, tempChar, strlen(tempChar));
}
xfree((void**) &tempChar);
}
}
}