One line fix for possible out-of-bounds issue in kmp_runtime.c
authorJonathan Peyton <jonathan.l.peyton@intel.com>
Tue, 26 May 2015 16:38:26 +0000 (16:38 +0000)
committerJonathan Peyton <jonathan.l.peyton@intel.com>
Tue, 26 May 2015 16:38:26 +0000 (16:38 +0000)
The variable j is now checked so there is no possible
out-of-bounds issue when accessing __kmp_nested_nth.nth[] array.

llvm-svn: 238216

openmp/runtime/src/kmp_runtime.c

index 4ab998b..195f8a1 100644 (file)
@@ -6626,7 +6626,7 @@ __kmp_do_middle_initialize( void )
 
     // If there were empty places in num_threads list (OMP_NUM_THREADS=,,2,3), correct them now
     j = 0;
-    while ( __kmp_nested_nth.used && ! __kmp_nested_nth.nth[ j ] ) {
+    while ( ( j < __kmp_nested_nth.used ) && ! __kmp_nested_nth.nth[ j ] ) {
         __kmp_nested_nth.nth[ j ] = __kmp_dflt_team_nth = __kmp_dflt_team_nth_ub = __kmp_avail_proc;
         j++;
     }