Skip to content

Commit

Permalink
Fix null-dereference in parseXMLMemberDynamicType (#5565)
Browse files Browse the repository at this point in the history
* Refs #22535. Add regression test.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #22535. Fix issue.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
MiguelCompany authored Jan 20, 2025
1 parent 90bebe3 commit c0e7929
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cpp/xmlparser/XMLDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,13 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType(
{
DynamicTypeBuilder::_ref_type inner_builder {factory->create_map_type(key_type, value_type,
length)};
if (!inner_builder)
{
EPROSIMA_LOG_ERROR(XMLPARSER,
"Error parsing map member type: `create_map_type` failed for key=`" << key_type <<
"`, value=`" << value_type << "`, length=`" << length << "`.");
return {};
}
std::vector<uint32_t> bounds;
dimensionsToArrayBounds(memberArray, bounds);
DynamicTypeBuilder::_ref_type builder = factory->create_array_type(
Expand Down
1 change: 1 addition & 0 deletions test/unittest/xmlparser/XMLParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ TEST_F(XMLParserTests, regressions)
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));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22101_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22535_profile_bin.xml", root));
Log::Flush();
}

Expand Down
1 change: 1 addition & 0 deletions test/unittest/xmlparser/regressions/22535_profile_bin.xml

Large diffs are not rendered by default.

0 comments on commit c0e7929

Please sign in to comment.