[Openmp-commits] [PATCH] D112806: [OpenMP][OMPT] Add two missing nullpointer checks in ompt-multiplex.h

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Oct 29 04:58:02 PDT 2021


protze.joachim created this revision.
protze.joachim added a reviewer: hbae.
protze.joachim added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
protze.joachim requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

In the functions ompt_multiplex_get_own_ompt_data
and ompt_multiplex_get_client_ompt_data in addition to
data being NULL, also the void pointer field "ptr" of
"data" could be NULL, leading to a subsequent 
segfault.
This patch add the corresponding checks.

Patch prepared by Semih Burak


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112806

Files:
  openmp/tools/multiplex/ompt-multiplex.h


Index: openmp/tools/multiplex/ompt-multiplex.h
===================================================================
--- openmp/tools/multiplex/ompt-multiplex.h
+++ openmp/tools/multiplex/ompt-multiplex.h
@@ -153,6 +153,8 @@
 static ompt_data_t *ompt_multiplex_get_own_ompt_data(ompt_data_t *data) {
   if (!data)
     return NULL;
+  if (!data->ptr)
+    return NULL;
   ompt_multiplex_data_pair_t *data_pair =
       (ompt_multiplex_data_pair_t *)data->ptr;
   return &(data_pair->own_data);
@@ -161,6 +163,8 @@
 static ompt_data_t *ompt_multiplex_get_client_ompt_data(ompt_data_t *data) {
   if (!data)
     return NULL;
+  if (!data->ptr)
+    return NULL;
   ompt_multiplex_data_pair_t *data_pair =
       (ompt_multiplex_data_pair_t *)data->ptr;
   return &(data_pair->client_data);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112806.383311.patch
Type: text/x-patch
Size: 787 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211029/8ac727ca/attachment.bin>


More information about the Openmp-commits mailing list