From 4f2fbaa2559a27f50d64d2d5fa33edcf5fd05220 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Wed, 8 Jan 2025 15:08:51 -0400 Subject: [PATCH] Fix NULL ptr use from dlerror() --- hcore/senseApis/senseApiManager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hcore/senseApis/senseApiManager.cpp b/hcore/senseApis/senseApiManager.cpp index 061577b..6585842 100644 --- a/hcore/senseApis/senseApiManager.cpp +++ b/hcore/senseApis/senseApiManager.cpp @@ -65,11 +65,13 @@ SenseApiLib& SenseApiManager::loadSenseApiLib(const std::string& libraryPath) if (!lib->handle) { - std::string error = dlerror() - ? dlerror() - : "Unknown error while opening shlib"; + const char *dlerr = dlerror(); + + std::string error = (dlerr + ? dlerr + : "Unknown error while opening shlib"); throw std::runtime_error( - std::string(__func__) + " - Cannot load library '" + std::string(__func__) + ": Cannot load library '" + libraryPath + "': " + error); }