diff --git a/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp b/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp index 05cbf53574..23e276028e 100644 --- a/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp +++ b/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp @@ -724,6 +724,12 @@ XMLP_ret XMLParser::parseXMLStructDynamicType( */ XMLP_ret ret = XMLP_ret::XML_OK; const char* name = p_root->Attribute(NAME); + if (nullptr == name || name[0] == '\0') + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Missing required attribute 'name' in 'structDcl'."); + return XMLP_ret::XML_ERROR; + } + p_dynamictypebuilder_t typeBuilder; // = types::DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); //typeBuilder->set_name(name); uint32_t mId = 0; diff --git a/test/unittest/xmlparser/XMLParserTests.cpp b/test/unittest/xmlparser/XMLParserTests.cpp index dfe1eba3b1..5629106e16 100644 --- a/test/unittest/xmlparser/XMLParserTests.cpp +++ b/test/unittest/xmlparser/XMLParserTests.cpp @@ -63,6 +63,7 @@ TEST_F(XMLParserTests, regressions) EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/18395_profile_bin.xml", root)); EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/19354_profile_bin.xml", root)); EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/19354_2_profile_bin.xml", root)); + EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/19851_profile_bin.xml", root)); EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/simple_participant_profiles_nok.xml", root)); EXPECT_EQ(XMLP_ret::XML_OK, XMLParser::loadXML("regressions/simple_participant_profiles_ok.xml", root)); } diff --git a/test/unittest/xmlparser/regressions/19851_profile_bin.xml b/test/unittest/xmlparser/regressions/19851_profile_bin.xml new file mode 100644 index 0000000000..db6b7a8427 --- /dev/null +++ b/test/unittest/xmlparser/regressions/19851_profile_bin.xml @@ -0,0 +1 @@ +