From 8b0ba2275a3958a63d165d8fb5ff4c0e3be7a2bd Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 11 Sep 2020 14:31:31 +0200 Subject: [PATCH] Check !!downtime->GetCheckable() before downtime->GetCheckable()->GetName() ... not to crash while removing a downtime from a disappeared checkable. --- lib/icinga/downtime.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp index f003bc746..1364f722c 100644 --- a/lib/icinga/downtime.cpp +++ b/lib/icinga/downtime.cpp @@ -345,10 +345,19 @@ void Downtime::RemoveDowntime(const String& id, bool cancelled, bool expired, co reason = ""; } - Log(LogInformation, "Downtime") - << "Removed downtime '" << downtime->GetName() << "' from checkable '" - << downtime->GetCheckable()->GetName() << "' (Reason: " << reason << ")."; + Log msg (LogInformation, "Downtime"); + msg << "Removed downtime '" << downtime->GetName() << "' from checkable"; + + { + auto checkable (downtime->GetCheckable()); + + if (checkable) { + msg << " '" << checkable->GetName() << "'"; + } + } + + msg << " (Reason: " << reason << ")."; } bool Downtime::CanBeTriggered()