]> granicus.if.org Git - icinga2/commitdiff
Fix crash in CreateObjectHandler::HandleRequest()
authorMichael Friedrich <michael.friedrich@icinga.com>
Mon, 5 Dec 2016 15:37:31 +0000 (16:37 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 5 Dec 2016 15:37:31 +0000 (16:37 +0100)
fixes #13409
refs #11684

lib/remote/createobjecthandler.cpp

index 97f993bbc9b4e4b39bceee176b7915de397b5b1f..b4cbbd924bb7c89cd38926c2f76db9e9f00678c1 100644 (file)
@@ -52,16 +52,22 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
        Array::Ptr templates = params->Get("templates");
        Dictionary::Ptr attrs = params->Get("attrs");
 
-       /* Put created objects into the local zone if not explicitely defined.
+       /* Put created objects into the local zone if not explicitly defined.
         * This allows additional zone members to sync the
         * configuration at some later point.
         */
        Zone::Ptr localZone = Zone::GetLocalZone();
        String localZoneName;
 
-       if (localZone && !attrs->Contains("zone")) {
+       if (localZone) {
                localZoneName = localZone->GetName();
-               attrs->Set("zone", localZoneName);
+
+               if (!attrs) {
+                       attrs = new Dictionary();
+                       attrs->Set("zone", localZoneName);
+               } else if (attrs && !attrs->Contains("zone")) {
+                       attrs->Set("zone", localZoneName);
+               }
        }
 
        Dictionary::Ptr result1 = new Dictionary();