From bbb69bd977745fc9b4a5b7da345426da208423f3 Mon Sep 17 00:00:00 2001 From: Bartel Sielski Date: Mon, 18 Mar 2024 12:47:36 +0100 Subject: [PATCH] upower: Initialize variables There are code paths in which some of these variables were used but not initialized, causing undefined behavior. --- src/modules/upower/upower.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/upower/upower.cpp b/src/modules/upower/upower.cpp index c31f9ea7..ad4c4732 100644 --- a/src/modules/upower/upower.cpp +++ b/src/modules/upower/upower.cpp @@ -315,12 +315,12 @@ auto UPower::update() -> void { return; } - UpDeviceKind kind; - UpDeviceState state; + UpDeviceKind kind = UP_DEVICE_KIND_UNKNOWN; + UpDeviceState state = UP_DEVICE_STATE_UNKNOWN; UpDeviceLevel level = UP_DEVICE_LEVEL_UNKNOWN; - double percentage; - gint64 time_empty; - gint64 time_full; + double percentage = 0.0; + gint64 time_empty = 0; + gint64 time_full = 0; gchar* icon_name{(char*)'\0'}; std::string percentString{""}; std::string time_format{""};