From 623751fb658772001cd41d2279055422bd1a6495 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Thu, 7 Oct 2010 11:11:52 +0200 Subject: [PATCH] Make sure get_last_updates() contains atleast one entry before calling .front() --- src/serviceholder.cpp | 3 ++- src/updater.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/serviceholder.cpp b/src/serviceholder.cpp index ed4efe0..1eee942 100644 --- a/src/serviceholder.cpp +++ b/src/serviceholder.cpp @@ -67,7 +67,8 @@ int Serviceholder::serialize_services() const BOOST_FOREACH(const Service::Ptr &service, OldServices) { - if ( ( service->get_last_updates().front() + ((time_t)service->get_update_interval()*60) ) >= current_time ) /*lint !e1793 */ // UpdateInterval timeout of service isn't expired. + if ( !service->get_last_updates().empty() && + ( service->get_last_updates().front() + ((time_t)service->get_update_interval()*60) ) >= current_time ) /*lint !e1793 */ // UpdateInterval timeout of service isn't expired. service_container->add_service(service); } diff --git a/src/updater.cpp b/src/updater.cpp index bbf3454..852b46b 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -241,7 +241,7 @@ void Updater::update_services(bool changed_to_online) const time_t current_time = time(NULL); // Try to get the lastupdated time of the actual service if there is one. - if ( service->get_last_updates().size() > 0 ) + if ( !service->get_last_updates().empty() ) lastupdated = service->get_last_updates().front(); /*lint !e1793 */ Log->print_check_service_update(hostname, current_time, lastupdated); -- 1.7.1