[Openmp-commits] [openmp] r358181 - Fixed possible out of bound array access.

Andrey Churbanov via Openmp-commits openmp-commits at lists.llvm.org
Thu Apr 11 08:03:44 PDT 2019


Author: achurbanov
Date: Thu Apr 11 08:03:44 2019
New Revision: 358181

URL: http://llvm.org/viewvc/llvm-project?rev=358181&view=rev
Log:
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

Modified:
    openmp/trunk/runtime/src/kmp_settings.cpp

Modified: openmp/trunk/runtime/src/kmp_settings.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_settings.cpp?rev=358181&r1=358180&r2=358181&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_settings.cpp (original)
+++ openmp/trunk/runtime/src/kmp_settings.cpp Thu Apr 11 08:03:44 2019
@@ -4462,10 +4462,10 @@ static void __kmp_stg_parse_hw_subset(ch
   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) {




More information about the Openmp-commits mailing list