diff options
author | Hansang Bae <hansang.bae@intel.com> | 2019-05-30 16:32:20 +0000 |
---|---|---|
committer | Hansang Bae <hansang.bae@intel.com> | 2019-05-30 16:32:20 +0000 |
commit | 48eeef98d8147c59f9db18c8d7e646741c28f738 (patch) | |
tree | 52c0b48d00681a133c59445c3a524080fb368e23 | |
parent | 93fe5cefbde9bfced3c6577219a98791ff7e3481 (diff) |
Add checks before pointer dereferencing
This change adds checks before dereferencing a pointer returned from a
function.
Differential Revision: https://reviews.llvm.org/D62224
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@362111 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | runtime/src/ompt-specific.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/src/ompt-specific.cpp b/runtime/src/ompt-specific.cpp index 99c4b61..63153d2 100644 --- a/runtime/src/ompt-specific.cpp +++ b/runtime/src/ompt-specific.cpp @@ -210,7 +210,8 @@ ompt_data_t *__ompt_get_thread_data_internal() { 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 **addr, size_t *size, int blocknum) { 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); |