From ba8a88acfb0103b4762e3598525377c744b79ac1 Mon Sep 17 00:00:00 2001 From: Lasse Luttermann Date: Tue, 14 May 2024 08:16:10 +0200 Subject: [PATCH 1/2] Do not try to compare a string that may be a null-pointer --- src/modules/upower.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/upower.cpp b/src/modules/upower.cpp index 7f0b3446..69e5b79e 100644 --- a/src/modules/upower.cpp +++ b/src/modules/upower.cpp @@ -370,6 +370,8 @@ void UPower::setDisplayDevice() { auto thisPtr{static_cast(user_data)}; upDevice.upDevice = static_cast(data); thisPtr->getUpDeviceInfo(upDevice); + if (upDevice.nativePath == nullptr) + return; if (0 == std::strcmp(upDevice.nativePath, thisPtr->nativePath_.c_str())) { // Unref current upDevice if (thisPtr->upDevice_.upDevice != NULL) g_object_unref(thisPtr->upDevice_.upDevice); From 3c075bcc53cd7ff1744dcb23e6c3345b28603af0 Mon Sep 17 00:00:00 2001 From: Lasse Luttermann Date: Tue, 14 May 2024 08:26:44 +0200 Subject: [PATCH 2/2] Fixed formatting --- src/modules/upower.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/upower.cpp b/src/modules/upower.cpp index 69e5b79e..fbbd6c4d 100644 --- a/src/modules/upower.cpp +++ b/src/modules/upower.cpp @@ -370,8 +370,7 @@ void UPower::setDisplayDevice() { auto thisPtr{static_cast(user_data)}; upDevice.upDevice = static_cast(data); thisPtr->getUpDeviceInfo(upDevice); - if (upDevice.nativePath == nullptr) - return; + if (upDevice.nativePath == nullptr) return; if (0 == std::strcmp(upDevice.nativePath, thisPtr->nativePath_.c_str())) { // Unref current upDevice if (thisPtr->upDevice_.upDevice != NULL) g_object_unref(thisPtr->upDevice_.upDevice);