From edb1bf25adb702f97256285afbcead6a2d437cf0 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Sun, 25 Oct 2026 08:57:52 +0100 Subject: [PATCH] Don't crash on systemd unit result --- server/start_systemd_unit.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/start_systemd_unit.cpp b/server/start_systemd_unit.cpp index e1e9353a..90955c22 100644 --- a/server/start_systemd_unit.cpp +++ b/server/start_systemd_unit.cpp @@ -162,9 +162,11 @@ void systemd_units_manager::on_unit_result( void * self_) { auto self = (systemd_units_manager *)(self_); - std::string_view state = unit_unit_get_active_state(unit); + const char * state = unit_unit_get_active_state(unit); + if (state == nullptr) + return; bool empty = self->units.empty(); - if (state == "inactive" or state == "failed") + if (state == std::string_view("inactive") or state == std::string_view("failed")) std::erase_if(self->units, [&](auto & o) { return o.get() == unit; }); if (self->state_changed_cb and self->units.empty() and not empty) self->state_changed_cb();