From: Gunnar Beutner Date: Wed, 15 Jun 2016 09:26:35 +0000 (+0200) Subject: Fix crash in ApiListener::PersistMessage X-Git-Tag: v2.5.0~264 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45919b4844804108ddb145aa52cd46f77c2a836f;p=icinga2 Fix crash in ApiListener::PersistMessage fixes #11946 --- diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index b099ef21b..c51a1a869 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -602,10 +602,13 @@ void ApiListener::PersistMessage(const Dictionary::Ptr& message, const ConfigObj pmessage->Set("timestamp", ts); pmessage->Set("message", JsonEncode(message)); - Dictionary::Ptr secname = new Dictionary(); - secname->Set("type", secobj->GetType()->GetName()); - secname->Set("name", secobj->GetName()); - pmessage->Set("secobj", secname); + + if (secobj) { + Dictionary::Ptr secname = new Dictionary(); + secname->Set("type", secobj->GetType()->GetName()); + secname->Set("name", secobj->GetName()); + pmessage->Set("secobj", secname); + } boost::mutex::scoped_lock lock(m_LogLock); if (m_LogFile) {