From ed28ae1b3f75f25b2089b47f5fe27e10a6a37b86 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 16 Jul 2013 10:18:03 +0200 Subject: [PATCH] compat: Make sure host is not null. --- components/compat/compatcomponent.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp index 695a9f624..b31a0e044 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(comment->Get("legacy_id")) << "\n" << "\t" << "entry_time=" << static_cast(comment->Get("entry_time")) << "\n" << "\t" << "entry_type=" << static_cast(comment->Get("entry_type")) << "\n"