[icinga-checkins] icinga.org: icinga2/master: compat: Make sure host is not null.

git at icinga.org git at icinga.org
Tue Jul 16 10:18:28 CEST 2013


Module: icinga2
Branch: master
Commit: ed28ae1b3f75f25b2089b47f5fe27e10a6a37b86
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=ed28ae1b3f75f25b2089b47f5fe27e10a6a37b86

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Tue Jul 16 10:18:03 2013 +0200

compat: Make sure host is not null.

---

 components/compat/compatcomponent.cpp |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp
index 695a9f6..b31a0e0 100644
--- a/components/compat/compatcomponent.cpp
+++ b/components/compat/compatcomponent.cpp
@@ -195,12 +195,16 @@ void CompatComponent::CommandPipeThread(const String& commandPath)
 void CompatComponent::DumpComments(std::ostream& fp, const Service::Ptr& owner, CompatObjectType type)
 {
 	Service::Ptr service;
-	Host::Ptr host;
 	Dictionary::Ptr comments = owner->GetComments();
 
 	if (!comments)
 		return;
 
+	Host::Ptr host = owner->GetHost();
+
+	if (!host)
+		return;
+
 	ObjectLock olock(comments);
 
 	String id;
@@ -215,7 +219,7 @@ void CompatComponent::DumpComments(std::ostream& fp, const Service::Ptr& owner,
 			fp << "servicecomment {" << "\n"
 			   << "\t" << "service_description=" << owner->GetShortName() << "\n";
 
-		fp << "\t" << "host_name=" << owner->GetHost()->GetName() << "\n"
+		fp << "\t" << "host_name=" << host->GetName() << "\n"
 		   << "\t" << "comment_id=" << static_cast<String>(comment->Get("legacy_id")) << "\n"
 		   << "\t" << "entry_time=" << static_cast<double>(comment->Get("entry_time")) << "\n"
 		   << "\t" << "entry_type=" << static_cast<long>(comment->Get("entry_type")) << "\n"





More information about the icinga-checkins mailing list