[Openmp-commits] [PATCH] D112174: [OpenMP] Fix possible NULL dereference

Andrey Churbanov via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Oct 27 06:55:03 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc704b25b4494: [OpenMP] libomp: Fix possible NULL dereference. (authored by AndreyChurbanov).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112174/new/

https://reviews.llvm.org/D112174

Files:
  openmp/runtime/src/ompt-general.cpp


Index: openmp/runtime/src/ompt-general.cpp
===================================================================
--- openmp/runtime/src/ompt-general.cpp
+++ openmp/runtime/src/ompt-general.cpp
@@ -346,9 +346,16 @@
         OMPT_VERBOSE_INIT_CONTINUED_PRINT("Success. \n");
         OMPT_VERBOSE_INIT_PRINT("Searching for ompt_start_tool in %s... ",
                                 fname);
+        dlerror(); // Clear any existing error
         start_tool = (ompt_start_tool_t)dlsym(h, "ompt_start_tool");
         if (!start_tool) {
-          OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n", dlerror());
+          char *error = dlerror();
+          if (error != NULL) {
+            OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n", error);
+          } else {
+            OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed: %s\n",
+                                              "ompt_start_tool = NULL");
+          }
         } else
 #elif KMP_OS_WINDOWS
       OMPT_VERBOSE_INIT_PRINT("Opening %s... ", fname);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112174.382657.patch
Type: text/x-patch
Size: 1011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20211027/45d392f7/attachment.bin>


More information about the Openmp-commits mailing list