From 224ef775c6f838ec6156d2efb05fdea5d505c3ab Mon Sep 17 00:00:00 2001 From: Lee Thomason Date: Fri, 16 Jun 2017 09:45:26 -0700 Subject: [PATCH] add test case --- xmltest.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/xmltest.cpp b/xmltest.cpp index 550bf75..1febf72 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -1754,6 +1754,52 @@ int main( int argc, const char ** argv ) } } + { + // Crashing reported via email. + const char* xml = + "" + "voice" + "1" + "" + "" + "" + "" + "" + "" + "" + ""; + + // It's not a good idea to delete elements as you walk the + // list. I'm not sure this technically should work; but it's + // an interesting test case. + XMLDocument doc; + XMLError err = doc.Parse(xml); + XMLElement* playlist = doc.FirstChildElement("playlist"); + + XMLTest("Crash bug parsing", err, XMLError::XML_SUCCESS); + XMLTest("Crash bug parsing", true, playlist != 0); + + tinyxml2::XMLElement* entry = playlist->FirstChildElement("entry"); + XMLTest("Crash bug parsing", true, entry != 0); + while (entry) { + tinyxml2::XMLElement* todelete = entry; + entry = entry->NextSiblingElement("entry"); + playlist->DeleteChild(todelete); + }; + tinyxml2::XMLElement* blank = playlist->FirstChildElement("blank"); + while (blank) { + tinyxml2::XMLElement* todelete = blank; + blank = blank->NextSiblingElement("blank"); + playlist->DeleteChild(todelete); + }; + + tinyxml2::XMLPrinter printer; + playlist->Accept(&printer); + printf("%s\n", printer.CStr()); + + // No test; it only need to not crash. + } + // ----------- Line Number Tracking -------------- { struct TestUtil: XMLVisitor