[Openmp-commits] [PATCH] D62224: Add checks before dereferencing pointers

Hansang Bae via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue May 21 15:36:19 PDT 2019


hbae created this revision.
hbae added reviewers: tlwilmar, jlpeyton, AndreyChurbanov.
hbae added a project: OpenMP.
Herald added a subscriber: jdoerfert.

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


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D62224

Files:
  runtime/src/ompt-specific.cpp


Index: runtime/src/ompt-specific.cpp
===================================================================
--- runtime/src/ompt-specific.cpp
+++ runtime/src/ompt-specific.cpp
@@ -210,7 +210,8 @@
 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 @@
     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);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62224.200601.patch
Type: text/x-patch
Size: 764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190521/89c0845a/attachment.bin>


More information about the Openmp-commits mailing list