forked from OSchip/llvm-project
[OpenMP] libomp: Fix possible NULL dereference.
According to dlsym description, the value of symbol could be NULL, and there is no error in this case. Thus dlerror will also return NULL in this case. We need to check the value returned by dlerror before printing it. Differential Revision: https://reviews.llvm.org/D112174
This commit is contained in:
parent
9f90347588
commit
c704b25b44
|
@ -346,9 +346,16 @@ ompt_try_start_tool(unsigned int omp_version, const char *runtime_version) {
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue