From d14a4a2b1aa6b4a9af15b345f1435e68103c5d26 Mon Sep 17 00:00:00 2001 From: ArneshRC <84434238+ArneshRC@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:00:13 +0530 Subject: [PATCH] fixed early dereference error --- src/modules/battery.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index f9f9cea4..2495b33a 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -701,7 +701,6 @@ void waybar::modules::Battery::setBarClass(std::string& state) { return classname.rfind(prefix, 0) == 0; }); - auto old_class = *old_class_it; auto new_class = prefix + state; // If the bar doesn't have any `battery-` class @@ -712,6 +711,8 @@ void waybar::modules::Battery::setBarClass(std::string& state) { return; } + auto old_class = *old_class_it; + // If the bar has a `battery-` class, // but `state` is empty if(state.empty()) {