From bd08f14cfcd862ac52add12cea100fed6cd7b61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Dom=C3=ADnguez=20L=C3=B3pez?= <116071334+Mario-DL@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:33:36 +0100 Subject: [PATCH] Address `XMLDynamicParser` regression (#5383) * Refs #22054: Add Regression test Signed-off-by: Mario Dominguez * Refs #22054: Add fix Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario Dominguez (cherry picked from commit fe295354e397ff1dc62f33035891d45c8938becd) --- src/cpp/xmlparser/XMLDynamicParser.cpp | 11 +++++++++-- test/unittest/xmlparser/XMLParserTests.cpp | 1 + .../xmlparser/regressions/22054_profile_bin.xml | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/unittest/xmlparser/regressions/22054_profile_bin.xml diff --git a/src/cpp/xmlparser/XMLDynamicParser.cpp b/src/cpp/xmlparser/XMLDynamicParser.cpp index 7412017ea20..21572dcef60 100644 --- a/src/cpp/xmlparser/XMLDynamicParser.cpp +++ b/src/cpp/xmlparser/XMLDynamicParser.cpp @@ -577,9 +577,16 @@ XMLP_ret XMLParser::parseXMLBitsetDynamicType( const char* baseType = p_root->Attribute(BASE_TYPE); if (baseType != nullptr) { - DynamicTypeBuilder::_ref_type parent_type_builder; + DynamicTypeBuilder::_ref_type parent_type_builder = nullptr; XMLProfileManager::getDynamicTypeBuilderByName(parent_type_builder, baseType); - DynamicType::_ref_type parent_type = parent_type_builder->build(); + + DynamicType::_ref_type parent_type = nullptr; + + if (nullptr != parent_type_builder) + { + parent_type = parent_type_builder->build(); + } + if (parent_type && (TK_BITSET == parent_type->get_kind() || TK_BITSET == traits::narrow(parent_type)->resolve_alias_enclosed_type()->get_kind())) diff --git a/test/unittest/xmlparser/XMLParserTests.cpp b/test/unittest/xmlparser/XMLParserTests.cpp index 6fac053d3b8..8675542db1a 100644 --- a/test/unittest/xmlparser/XMLParserTests.cpp +++ b/test/unittest/xmlparser/XMLParserTests.cpp @@ -84,6 +84,7 @@ TEST_F(XMLParserTests, regressions) EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21223_profile_bin.xml", root)); EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21334_profile_bin.xml", root)); EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21856_profile_bin.xml", root)); + EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22054_profile_bin.xml", root)); Log::Flush(); } diff --git a/test/unittest/xmlparser/regressions/22054_profile_bin.xml b/test/unittest/xmlparser/regressions/22054_profile_bin.xml new file mode 100644 index 00000000000..47f12da9eb6 --- /dev/null +++ b/test/unittest/xmlparser/regressions/22054_profile_bin.xml @@ -0,0 +1 @@ + \ No newline at end of file