]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5267] Fixed LoggingInfo::toElement
authorFrancis Dupont <fdupont@isc.org>
Sun, 1 Oct 2017 17:25:10 +0000 (19:25 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sun, 1 Oct 2017 17:25:10 +0000 (19:25 +0200)
src/lib/dhcpsrv/logging_info.cc

index 9cedf6c4ca05be7eb4e0334d82ca2446e15a64af..d052273c25fe79ffe26ff83f81a2a13132ed77e8 100644 (file)
@@ -161,14 +161,16 @@ LoggingInfo::toElement() const {
     ElementPtr result = Element::createMap();
     // Set name
     result->set("name", Element::create(name_));
-    // Set output_options
-    ElementPtr options = Element::createList();
-    for (std::vector<LoggingDestination>::const_iterator dest =
-             destinations_.cbegin();
-         dest != destinations_.cend(); ++dest) {
-        options->add(dest->toElement());
+    // Set output_options if not empty
+    if (!destinations_.empty()) {
+        ElementPtr options = Element::createList();
+        for (std::vector<LoggingDestination>::const_iterator dest =
+                 destinations_.cbegin();
+             dest != destinations_.cend(); ++dest) {
+            options->add(dest->toElement());
+        }
+        result->set("output_options", options);
     }
-    result->set("output_options", options);
     // Set severity
     std::string severity;
     switch (severity_) {