[icinga-checkins] icinga.org: icinga2/master: Fix crash in CreateObjectHandler:: HandleRequest()

git at icinga.org git at icinga.org
Mon Dec 5 16:38:14 CET 2016


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

Author: Michael Friedrich <michael.friedrich at icinga.com>
Date:   Mon Dec  5 16:37:31 2016 +0100

Fix crash in CreateObjectHandler::HandleRequest()

fixes #13409
refs #11684

---

 lib/remote/createobjecthandler.cpp |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/remote/createobjecthandler.cpp b/lib/remote/createobjecthandler.cpp
index 97f993b..b4cbbd9 100644
--- a/lib/remote/createobjecthandler.cpp
+++ b/lib/remote/createobjecthandler.cpp
@@ -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();



More information about the icinga-checkins mailing list