Check !!downtime->GetCheckable() before downtime->GetCheckable()->GetName()

... not to crash while removing a downtime from a disappeared checkable.
This commit is contained in:
Alexander A. Klimov 2020-09-11 14:31:31 +02:00
parent e9b8fc234b
commit 8b0ba2275a
1 changed files with 12 additions and 3 deletions

View File

@ -345,10 +345,19 @@ void Downtime::RemoveDowntime(const String& id, bool cancelled, bool expired, co
reason = "<unknown>";
}
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()