From: Gunnar Beutner Date: Thu, 20 Mar 2014 14:37:59 +0000 (+0100) Subject: Make duplicate object definitions an error. X-Git-Tag: v0.0.9~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95bf7ca560397f989f9e2e82d673d17a57b410be;p=icinga2 Make duplicate object definitions an error. Fixes #3638 --- diff --git a/lib/config/config_parser.yy b/lib/config/config_parser.yy index 80ebe126b..87ed3a378 100644 --- a/lib/config/config_parser.yy +++ b/lib/config/config_parser.yy @@ -366,6 +366,17 @@ object_declaration identifier T_STRING object_inherits_specifier expressionlist { ConfigItemBuilder::Ptr item = make_shared(yylloc); + ConfigItem::Ptr oldItem = ConfigItem::GetObject($3, $4); + + if (oldItem) { + std::ostringstream msgbuf; + msgbuf << "Object '" << $4 << "' of type '" << $3 << "' re-defined; previous definition: " << oldItem->GetDebugInfo(); + free($3); + free($4); + delete $5; + BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str())); + } + item->SetType($3); if (strchr($4, '!') != NULL) {