From 4cbe14542ed9761b0c9de8aa835e45e29ba8c87b Mon Sep 17 00:00:00 2001 From: Mario Dominguez <mariodominguez@eprosima.com> Date: Mon, 16 Dec 2024 16:16:42 +0100 Subject: [PATCH] Refs #22484: Fix Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com> --- src/cpp/xmlparser/XMLDynamicParser.cpp | 42 +++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/cpp/xmlparser/XMLDynamicParser.cpp b/src/cpp/xmlparser/XMLDynamicParser.cpp index 21572dcef60..abfb976af00 100644 --- a/src/cpp/xmlparser/XMLDynamicParser.cpp +++ b/src/cpp/xmlparser/XMLDynamicParser.cpp @@ -1309,14 +1309,46 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType( if (!isArray) { - member = factory->create_sequence_type(content_type, length)->build(); + DynamicTypeBuilder::_ref_type inner_builder{factory->create_sequence_type(content_type, length)}; + if (nullptr != inner_builder) + { + member = inner_builder->build(); + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, + "Error parsing sequence element type: Cannot recognize inner content of member: " << + memberType); + return {}; + } } else { - DynamicTypeBuilder::_ref_type inner_builder {factory->create_sequence_type(content_type, length)}; - std::vector<uint32_t> bounds; - dimensionsToArrayBounds(memberArray, bounds); - member = factory->create_array_type(inner_builder->build(), bounds)->build(); + DynamicTypeBuilder::_ref_type inner_builder{factory->create_sequence_type(content_type, length)}; + if (nullptr != inner_builder) + { + std::vector<uint32_t> bounds; + dimensionsToArrayBounds(memberArray, bounds); + DynamicTypeBuilder::_ref_type sub_builder{factory->create_array_type(inner_builder->build(), bounds)}; + if (nullptr != sub_builder) + { + member = sub_builder->build(); + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, + "Error parsing sequence element type: Cannot recognize inner content of member: " << + memberType); + return {}; + } + } + else + { + EPROSIMA_LOG_ERROR(XMLPARSER, + "Error parsing sequence element type: Cannot recognize inner content of member: " << + memberType); + return {}; + } } } else if (p_root->Attribute(MAP_MAXLENGTH) != nullptr)