[OpenMP] Check loc for NULL before dereferencing it
authorBryan Chan <bryan.chan@huawei.com>
Mon, 7 Jun 2021 14:37:24 +0000 (10:37 -0400)
committerBryan Chan <bryan.chan@huawei.com>
Mon, 7 Jun 2021 14:45:48 +0000 (10:45 -0400)
The ident_t * argument in __kmp_get_monotonicity was being used without
a customary NULL check, causing the function to crash in a Debug build.
Release builds were not affected thanks to dead store elimination.

openmp/runtime/src/kmp_dispatch.cpp

index d8e935d..c2e60fc 100644 (file)
@@ -77,7 +77,7 @@ static inline int __kmp_get_monotonicity(ident_t *loc, enum sched_type schedule,
 
   // Let default be monotonic for executables
   // compiled with OpenMP* 4.5 or less compilers
-  if (loc->get_openmp_version() < 50)
+  if (loc != NULL && loc->get_openmp_version() < 50)
     monotonicity = SCHEDULE_MONOTONIC;
 
   if (use_hier || __kmp_force_monotonic)