[icinga-checkins] icinga.org: icinga2/master: Fix crash in CheckResult cluster handlers

git at icinga.org git at icinga.org
Fri Nov 11 16:30:00 CET 2016


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

Author: Michael Friedrich <michael.friedrich at icinga.com>
Date:   Thu Nov 10 20:00:38 2016 +0100

Fix crash in CheckResult cluster handlers

fixes #13151

---

 lib/icinga/clusterevents.cpp |   51 ++++++++++++++++++++++++++++++++----------
 1 file changed, 39 insertions(+), 12 deletions(-)

diff --git a/lib/icinga/clusterevents.cpp b/lib/icinga/clusterevents.cpp
index 2e15fdb..1f09523 100644
--- a/lib/icinga/clusterevents.cpp
+++ b/lib/icinga/clusterevents.cpp
@@ -132,9 +132,15 @@ Value ClusterEvents::CheckResultAPIHandler(const MessageOrigin::Ptr& origin, con
 	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);
+
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
 	}
 
 	if (!cr)
@@ -833,13 +839,20 @@ Value ClusterEvents::SendNotificationsAPIHandler(const MessageOrigin::Ptr& origi
 	}
 
 	CheckResult::Ptr cr;
+	Array::Ptr vperf;
 
 	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);
+
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
 	}
 
 	NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
@@ -919,13 +932,20 @@ Value ClusterEvents::NotificationSentUserAPIHandler(const MessageOrigin::Ptr& or
 	}
 
 	CheckResult::Ptr cr;
+	Array::Ptr vperf;
 
 	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);
+
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
 	}
 
 	NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));
@@ -1027,13 +1047,20 @@ Value ClusterEvents::NotificationSentToAllUsersAPIHandler(const MessageOrigin::P
 	}
 
 	CheckResult::Ptr cr;
+	Array::Ptr vperf;
 
 	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);
+
+		if (vcr && vcr->Contains("performance_data")) {
+			vperf = vcr->Get("performance_data");
+
+			if (vperf)
+				vcr->Remove("performance_data");
+
+			Deserialize(cr, vcr, true);
+		}
 	}
 
 	NotificationType type = static_cast<NotificationType>(static_cast<int>(params->Get("type")));



More information about the icinga-checkins mailing list