From 6291fa4b781d3102d5ee4ade5776ac0fd30d578f Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Wed, 15 Mar 2017 12:54:07 +0000 Subject: [PATCH] - detect empty array size for globals and initialize as pointer --- src/stubser/cfile_parser.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/stubser/cfile_parser.c b/src/stubser/cfile_parser.c index 6a8aceb..c159485 100644 --- a/src/stubser/cfile_parser.c +++ b/src/stubser/cfile_parser.c @@ -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); } } }