From 9efb6b0b66eefa8394e34c12bfd993850e7f5244 Mon Sep 17 00:00:00 2001 From: dinghao188 <467682352@qq.com> Date: Fri, 17 Sep 2021 17:49:01 +0800 Subject: [PATCH] fix assertion - Assertion '_elementPool.CurrentAllocs() == _elementPool.Untracked()' failed. --- tinyxml2.cpp | 6 +++--- xmltest.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index d32b2b3..e4e79ca 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1077,7 +1077,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) StrPair endTag; p = node->ParseDeep( p, &endTag, curLineNumPtr ); if ( !p ) { - DeleteNode( node ); + _document->DeleteNode( node ); if ( !_document->Error() ) { _document->SetError( XML_ERROR_PARSING, initialLineNum, 0); } @@ -1110,7 +1110,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) } if ( !wellLocated ) { _document->SetError( XML_ERROR_PARSING_DECLARATION, initialLineNum, "XMLDeclaration value=%s", decl->Value()); - DeleteNode( node ); + _document->DeleteNode( node ); break; } } @@ -1145,7 +1145,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) } if ( mismatch ) { _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, initialLineNum, "XMLElement name=%s", ele->Name()); - DeleteNode( node ); + _document->DeleteNode( node ); break; } } diff --git a/xmltest.cpp b/xmltest.cpp index 7f196f1..98ed094 100755 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -2147,8 +2147,8 @@ int main( int argc, const char ** argv ) // successful loads should clear the error XMLDocument doc; XMLTest( "Should be no error initially", false, doc.Error() ); - doc.LoadFile( "resources/no-such-file.xml" ); - XMLTest( "No such file - should fail", true, doc.Error() ); + doc.LoadFile( "resources/xmltest-5330.xml" ); + XMLTest( "parse errors occur - should fail", true, doc.Error() ); doc.LoadFile( "resources/dream.xml" ); XMLTest( "Error should be cleared", false, doc.Error() );