Add checks before pointer dereferencing

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

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

llvm-svn: 362111
This commit is contained in:
Hansang Bae 2019-05-30 16:32:20 +00:00
parent 700fdb1070
commit 7c75ac0c60
1 changed files with 5 additions and 1 deletions

View File

@ -210,6 +210,7 @@ ompt_data_t *__ompt_get_thread_data_internal() {
void __ompt_thread_assign_wait_id(void *variable) {
kmp_info_t *ti = ompt_get_thread();
if (ti)
ti->th.ompt_thread_info.wait_id = (ompt_wait_id_t)(uintptr_t)variable;
}
@ -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);