From 8fd454fbb1457a34031a53baa16d2bacc77bba1b Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 13 Sep 2016 22:14:11 +0200 Subject: [PATCH] Fix crash in ClusterEvents::SendNotificationsAPIHandler fixes #12718 --- lib/icinga/clusterevents.cpp | 60 +++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/lib/icinga/clusterevents.cpp b/lib/icinga/clusterevents.cpp index 0128e7a23..2e15fdb3f 100644 --- a/lib/icinga/clusterevents.cpp +++ b/lib/icinga/clusterevents.cpp @@ -126,13 +126,19 @@ Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, con if (!params) return Empty; - CheckResult::Ptr cr = new CheckResult(); - - Dictionary::Ptr vcr = params->Get("cr"); - Array::Ptr vperf = vcr->Get("performance_data"); - vcr->Remove("performance_data"); + CheckResult::Ptr cr; + Array::Ptr vperf; + + if (params->Contains("cr")) { + cr = new CheckResult(); + Dictionary::Ptr vcr = params->Get("cr"); + vperf = vcr->Get("performance_data"); + vcr->Remove("performance_data"); + Deserialize(cr, vcr, true); + } - Deserialize(cr, params->Get("cr"), true); + if (!cr) + return Empty; Array::Ptr rperf = new Array(); @@ -826,13 +832,15 @@ Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origi return Empty; } - CheckResult::Ptr cr = new CheckResult(); + CheckResult::Ptr cr; - Dictionary::Ptr vcr = params->Get("cr"); - Array::Ptr vperf = vcr->Get("performance_data"); - vcr->Remove("performance_data"); - - Deserialize(cr, params->Get("cr"), true); + if (params->Contains("cr")) { + cr = new CheckResult(); + Dictionary::Ptr vcr = params->Get("cr"); + Array::Ptr vperf = vcr->Get("performance_data"); + vcr->Remove("performance_data"); + Deserialize(cr, vcr, true); + } NotificationType type = static_cast(static_cast(params->Get("type"))); String author = params->Get("author"); @@ -910,13 +918,15 @@ Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& or return Empty; } - CheckResult::Ptr cr = new CheckResult(); + CheckResult::Ptr cr; - Dictionary::Ptr vcr = params->Get("cr"); - Array::Ptr vperf = vcr->Get("performance_data"); - vcr->Remove("performance_data"); - - Deserialize(cr, params->Get("cr"), true); + if (params->Contains("cr")) { + cr = new CheckResult(); + Dictionary::Ptr vcr = params->Get("cr"); + Array::Ptr vperf = vcr->Get("performance_data"); + vcr->Remove("performance_data"); + Deserialize(cr, vcr, true); + } NotificationType type = static_cast(static_cast(params->Get("type"))); String author = params->Get("author"); @@ -1016,13 +1026,15 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P return Empty; } - CheckResult::Ptr cr = new CheckResult(); + CheckResult::Ptr cr; - Dictionary::Ptr vcr = params->Get("cr"); - Array::Ptr vperf = vcr->Get("performance_data"); - vcr->Remove("performance_data"); - - Deserialize(cr, params->Get("cr"), true); + if (params->Contains("cr")) { + cr = new CheckResult(); + Dictionary::Ptr vcr = params->Get("cr"); + Array::Ptr vperf = vcr->Get("performance_data"); + vcr->Remove("performance_data"); + Deserialize(cr, vcr, true); + } NotificationType type = static_cast(static_cast(params->Get("type"))); String author = params->Get("author"); -- 2.40.0