]> granicus.if.org Git - icinga2/commitdiff
Fix crash in ClusterEvents::SendNotificationsAPIHandler
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 13 Sep 2016 20:14:11 +0000 (22:14 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 13 Sep 2016 20:14:11 +0000 (22:14 +0200)
fixes #12718

lib/icinga/clusterevents.cpp

index 0128e7a23ba2a9b538e5d0cf52cd11a93833c9a6..2e15fdb3f95bc8e0bfab7280ae2a4a9a6d401c70 100644 (file)
@@ -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<NotificationType>(static_cast<int>(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<NotificationType>(static_cast<int>(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<NotificationType>(static_cast<int>(params->Get("type")));
        String author = params->Get("author");