Skip to content

Commit

Permalink
Handle nullptr in parseXMLStructDynamicType (#5080)
Browse files Browse the repository at this point in the history
* Refs #21334: Handle nullptr in parseXMLStructDynamicType

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>

* Refs #21334: uncrustify

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>

---------

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
  • Loading branch information
elianalf authored Jul 18, 2024
1 parent b0eb813 commit de9136d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cpp/xmlparser/XMLDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,16 @@ XMLP_ret XMLParser::parseXMLStructDynamicType(
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_STRUCTURE == parent_type->get_kind() ||
TK_STRUCTURE ==
traits<DynamicType>::narrow<DynamicTypeImpl>(parent_type)->resolve_alias_enclosed_type()->get_kind()))
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 @@ -82,6 +82,7 @@ TEST_F(XMLParserTests, regressions)
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21154_profile_bin.xml", root));
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));
Log::Flush();
}

Expand Down
Loading

0 comments on commit de9136d

Please sign in to comment.