Fix crash in ApiListener::PersistMessage

fixes #11946
This commit is contained in:
Gunnar Beutner 2016-06-15 11:26:35 +02:00
parent ace6882b59
commit 45919b4844
1 changed files with 7 additions and 4 deletions

View File

@ -602,10 +602,13 @@ void ApiListener::PersistMessage(const Dictionary::Ptr& message, const ConfigObj
pmessage->Set("timestamp", ts); pmessage->Set("timestamp", ts);
pmessage->Set("message", JsonEncode(message)); pmessage->Set("message", JsonEncode(message));
Dictionary::Ptr secname = new Dictionary();
secname->Set("type", secobj->GetType()->GetName()); if (secobj) {
secname->Set("name", secobj->GetName()); Dictionary::Ptr secname = new Dictionary();
pmessage->Set("secobj", secname); secname->Set("type", secobj->GetType()->GetName());
secname->Set("name", secobj->GetName());
pmessage->Set("secobj", secname);
}
boost::mutex::scoped_lock lock(m_LogLock); boost::mutex::scoped_lock lock(m_LogLock);
if (m_LogFile) { if (m_LogFile) {