这是indexloc提供的服务,不要输入任何密码
Skip to content

Guard against possible null pointer dereferences. #97426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions tensorflow/lite/delegates/gpu/cl/opencl_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ absl::Status LoadOpenCLOnce() {
typedef void (*enableOpenCL_t)();
enableOpenCL_t enableOpenCL =
reinterpret_cast<enableOpenCL_t>(dlsym(libopencl, "enableOpenCL"));
enableOpenCL();
LoadOpenCLFunctions(libopencl, true);
return absl::OkStatus();
if (enableOpenCL != nullptr) {
enableOpenCL();
LoadOpenCLFunctions(libopencl, true);
return absl::OkStatus();
}
}
}
#else
Expand All @@ -148,7 +150,9 @@ absl::Status LoadOpenCLOnce() {
LoadOpenCLFunctions(libopencl, false);
return absl::OkStatus();
}
TFLITE_LOG(INFO) << "Failed to load OpenCL library with dlopen: " << dlerror()
const char* dlerror_result = dlerror();
TFLITE_LOG(INFO) << "Failed to load OpenCL library with dlopen: "
<< (dlerror_result ? dlerror_result : "unknown error")
<< ". Trying ICD loader.";
// Check if OpenCL functions are found via OpenCL ICD Loader.
LoadOpenCLFunctions(libopencl, false);
Expand All @@ -162,7 +166,8 @@ absl::Status LoadOpenCLOnce() {
return absl::UnknownError("OpenCL is not supported.");
}
// record error
std::string error(dlerror());
dlerror_result = dlerror();
std::string error(dlerror_result ? dlerror_result : "unknown error");
return absl::UnknownError(
absl::StrCat("Can not open OpenCL library on this device - ", error));
#endif
Expand Down