Fixed possible out of bound array access.

The check of index value moved to before the write to the array.

Differential Revision: https://reviews.llvm.org/D60471

llvm-svn: 358181
This commit is contained in:
Andrey Churbanov 2019-04-11 15:03:44 +00:00
parent d843da6218
commit 705384be97
1 changed files with 2 additions and 2 deletions

View File

@ -4462,10 +4462,10 @@ static void __kmp_stg_parse_hw_subset(char const *name, char const *value,
pos = input;
components[level++] = pos;
while ((pos = strchr(pos, ','))) {
if (level >= MAX_T_LEVEL)
goto err; // too many components provided
*pos = '\0'; // modify input and avoid more copying
components[level++] = ++pos; // expect something after ","
if (level > MAX_T_LEVEL)
goto err; // too many components provided
}
// Check each component
for (int i = 0; i < level; ++i) {