From d8cd8b68c388fe3706f68d1d1d49eb206192cc41 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sun, 1 Oct 2017 19:25:10 +0200 Subject: [PATCH] [5267] Fixed LoggingInfo::toElement --- src/lib/dhcpsrv/logging_info.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/lib/dhcpsrv/logging_info.cc b/src/lib/dhcpsrv/logging_info.cc index 9cedf6c4ca..d052273c25 100644 --- a/src/lib/dhcpsrv/logging_info.cc +++ b/src/lib/dhcpsrv/logging_info.cc @@ -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::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::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_) { -- 2.47.2