From 7058ec8d4e2e47e65d59054a1aaa5fc4b6dbcaf3 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 15 Oct 2024 13:39:16 +0200 Subject: [PATCH 1/2] Refs #21856: Regression test Signed-off-by: Mario Dominguez --- test/unittest/xmlparser/XMLParserTests.cpp | 1 + test/unittest/xmlparser/regressions/21856_profile_bin.xml | 1 + 2 files changed, 2 insertions(+) create mode 100644 test/unittest/xmlparser/regressions/21856_profile_bin.xml diff --git a/test/unittest/xmlparser/XMLParserTests.cpp b/test/unittest/xmlparser/XMLParserTests.cpp index d94e6076f79..6fac053d3b8 100644 --- a/test/unittest/xmlparser/XMLParserTests.cpp +++ b/test/unittest/xmlparser/XMLParserTests.cpp @@ -83,6 +83,7 @@ TEST_F(XMLParserTests, regressions) EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21181_profile_bin.xml", root)); 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)); Log::Flush(); } diff --git a/test/unittest/xmlparser/regressions/21856_profile_bin.xml b/test/unittest/xmlparser/regressions/21856_profile_bin.xml new file mode 100644 index 00000000000..c55dda5dd9b --- /dev/null +++ b/test/unittest/xmlparser/regressions/21856_profile_bin.xml @@ -0,0 +1 @@ +le+68ÌÏnnpfile+/>pofilï_tyna+00000000000000000001ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ6744073709551616ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿÿ>pfile+/>pofilï_tynaÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ/4" />pfile+/>pofilï_tyna+30ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ/4" />pfile+/pofilï_tyna+30ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿ>pfile+/>pofilï_tyna+257pÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ>pfile+/>pofilï_tyna+000 0000000000000001ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ"ÿÿ4" />pofilï_tyna+30ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþÿÿ>pfile+/>pofilï_tyne+257pÿÿÿÿÿÿÿÿÿ$ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ>pfile+/>pofilï_tyna+00000000000000000000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ>pfile+/>pofilï_tyna+31ÿÿ>pfile+/>pofilï_tyna+257pÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ>pfile+/>pofilï_tyna+6pÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ>pfile+/>pofilï_tyna+00000000000000000000ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ>pfile+/>pofilï_tyna+31ÿÿ>pfile+/>pofilï_tyna+257pÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ/4" />pfile+/>pofilï_tyna+25"uint64" name=":" arrayDimensions="ÿÿÜÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ/4" />pfile+/>pofilï_tyna+31ÿÿ>pfile+/> \ No newline at end of file From 4a9742f491a68e04dfd3ad3e9726552261a95c7f Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 15 Oct 2024 13:39:22 +0200 Subject: [PATCH 2/2] Refs #21856: Fix Signed-off-by: Mario Dominguez --- src/cpp/xmlparser/XMLDynamicParser.cpp | 176 ++++++++++++++++++++----- 1 file changed, 140 insertions(+), 36 deletions(-) diff --git a/src/cpp/xmlparser/XMLDynamicParser.cpp b/src/cpp/xmlparser/XMLDynamicParser.cpp index 8f4549131ef..7412017ea20 100644 --- a/src/cpp/xmlparser/XMLDynamicParser.cpp +++ b/src/cpp/xmlparser/XMLDynamicParser.cpp @@ -1391,9 +1391,14 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( length)}; std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( inner_builder->build(), - bounds)->build(); + bounds); + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, BOOLEAN, BOOLEAN_len) == 0) @@ -1406,9 +1411,14 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_BOOLEAN), - bounds)->build(); + bounds); + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, CHAR, CHAR_len) == 0) @@ -1421,9 +1431,14 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_CHAR8), - bounds)->build(); + bounds); + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, WCHAR, WCHAR_len) == 0) @@ -1436,9 +1451,14 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_CHAR16), - bounds)->build(); + bounds); + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, TBYTE, TBYTE_len) == 0 @@ -1452,9 +1472,14 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_BYTE), - bounds)->build(); + bounds); + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, UINT8, UINT8_len) == 0) @@ -1467,9 +1492,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_UINT8), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, INT8, INT8_len) == 0) @@ -1482,9 +1513,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_INT8), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, SHORT, SHORT_len) == 0) @@ -1497,9 +1534,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_INT16), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, LONG, LONG_len) == 0) @@ -1512,9 +1555,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_INT32), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, ULONG, ULONG_len) == 0) @@ -1527,9 +1576,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_UINT32), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, USHORT, USHORT_len) == 0) @@ -1542,9 +1597,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_UINT16), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, LONGLONG, LONGLONG_len) == 0) @@ -1557,9 +1618,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_INT64), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, ULONGLONG, ULONGLONG_len) == 0) @@ -1572,9 +1639,18 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_UINT64), - bounds)->build(); + bounds); + + if (nullptr != builder) + { + member = builder->build(); + } + else + { + member = nullptr; + } } } else if (strncmp(memberType, FLOAT, FLOAT_len) == 0) @@ -1587,9 +1663,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_FLOAT32), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, DOUBLE, DOUBLE_len) == 0) @@ -1602,9 +1684,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_FLOAT64), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, LONGDOUBLE, LONGDOUBLE_len) == 0) @@ -1617,9 +1705,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( factory->get_primitive_type(TK_FLOAT128), - bounds)->build(); + bounds); + + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else if (strncmp(memberType, STRING, STRING_len) == 0) @@ -1691,9 +1785,14 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector boundsArray; dimensionsToArrayBounds(memberArray, boundsArray); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( wstring_builder->build(), - boundsArray)->build(); + boundsArray); + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } } else // Complex type? @@ -1718,9 +1817,14 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( { std::vector bounds; dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type( + DynamicTypeBuilder::_ref_type builder = factory->create_array_type( type, - bounds)->build(); + bounds); + member = nullptr; + if (nullptr != builder) + { + member = builder->build(); + } } }