[icinga-checkins] icinga.org: icinga2/fix/api-sync-repl-11684: Fix crash in ApiListener:: PersistMessage

git at icinga.org git at icinga.org
Wed Jun 15 17:50:20 CEST 2016


Module: icinga2
Branch: fix/api-sync-repl-11684
Commit: 45919b4844804108ddb145aa52cd46f77c2a836f
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=45919b4844804108ddb145aa52cd46f77c2a836f

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Jun 15 11:26:35 2016 +0200

Fix crash in ApiListener::PersistMessage

fixes #11946

---

 lib/remote/apilistener.cpp |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp
index b099ef2..c51a1a8 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) {



More information about the icinga-checkins mailing list