Skip to content

Commit

Permalink
Fix oss-fuzz 43650 (#2655)
Browse files Browse the repository at this point in the history
* Refs #13513. Regression test.

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

* Refs #13513. Fixed issue.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
(cherry picked from commit 6e6908a)

Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
mergify[bot] and MiguelCompany authored Apr 29, 2022
1 parent 6d70a27 commit 290bfd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/cpp/rtps/xmlparser/XMLDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,17 @@ XMLP_ret XMLParser::parseXMLAliasDynamicType(
if (valueBuilder != nullptr)
{
const char* name = p_root->Attribute(NAME);
p_dynamictypebuilder_t typeBuilder =
types::DynamicTypeBuilderFactory::get_instance()->create_alias_builder(valueBuilder, name);
XMLProfileManager::insertDynamicTypeByName(name, typeBuilder);
if (name != nullptr)
{
p_dynamictypebuilder_t typeBuilder =
types::DynamicTypeBuilderFactory::get_instance()->create_alias_builder(valueBuilder, name);
XMLProfileManager::insertDynamicTypeByName(name, typeBuilder);
}
else
{
logError(XMLPARSER, "Error parsing alias type: No name attribute given.");
ret = XMLP_ret::XML_ERROR;
}
}
else
{
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 @@ -57,6 +57,7 @@ TEST_F(XMLParserTests, regressions)
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/12736.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/13418.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/13454.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/13513.xml", root));
}

TEST_F(XMLParserTests, NoFile)
Expand Down
1 change: 1 addition & 0 deletions test/unittest/xmlparser/regressions/13513.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<types><type><typedef type="int8"/></type></types>

0 comments on commit 290bfd5

Please sign in to comment.