[Openmp-commits] [openmp] r362111 - Add checks before pointer dereferencing

Hansang Bae via Openmp-commits openmp-commits at lists.llvm.org
Thu May 30 09:32:20 PDT 2019


Author: hbae
Date: Thu May 30 09:32:20 2019
New Revision: 362111

URL: http://llvm.org/viewvc/llvm-project?rev=362111&view=rev
Log:
Add checks before pointer dereferencing

This change adds checks before dereferencing a pointer returned from a
function.

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

Modified:
    openmp/trunk/runtime/src/ompt-specific.cpp

Modified: openmp/trunk/runtime/src/ompt-specific.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-specific.cpp?rev=362111&r1=362110&r2=362111&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-specific.cpp (original)
+++ openmp/trunk/runtime/src/ompt-specific.cpp Thu May 30 09:32:20 2019
@@ -210,7 +210,8 @@ ompt_data_t *__ompt_get_thread_data_inte
 void __ompt_thread_assign_wait_id(void *variable) {
   kmp_info_t *ti = ompt_get_thread();
 
-  ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t)(uintptr_t)variable;
+  if (ti)
+    ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t)(uintptr_t)variable;
 }
 
 int __ompt_get_state_internal(ompt_wait_id_t *omp_wait_id) {
@@ -432,6 +433,9 @@ int __ompt_get_task_memory_internal(void
     return 0; // support only a single block
 
   kmp_info_t *thr = ompt_get_thread();
+  if (!thr)
+    return 0;
+
   kmp_taskdata_t *taskdata = thr->th.th_current_task;
   kmp_task_t *task = KMP_TASKDATA_TO_TASK(taskdata);
 




More information about the Openmp-commits mailing list