From 54f059c9007b48e4ff700ac587cbb137fff91fb7 Mon Sep 17 00:00:00 2001 From: Bryan Chan Date: Mon, 7 Jun 2021 10:37:24 -0400 Subject: [PATCH] [OpenMP] Check loc for NULL before dereferencing it 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmp/runtime/src/kmp_dispatch.cpp b/openmp/runtime/src/kmp_dispatch.cpp index d8e935d750807..c2e60fce9ed59 100644 --- a/openmp/runtime/src/kmp_dispatch.cpp +++ b/openmp/runtime/src/kmp_dispatch.cpp @@ -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)