leethomason / tinyxml2

TinyXML2 is a simple, small, efficient, C++ XML parser that can be easily integrated into other programs.
zlib License
5.11k stars 1.84k forks source link

Header causes crash processing XML file #1001

Closed AcuarioCat closed 1 month ago

AcuarioCat commented 1 month ago

I have an XML file that has a header that is causing the XML parser to crash.

`

static const char* xml = "<?xml version=\"1.0\"?>" "<gpx xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/1\" version=\"1.1\" creator=\"PocketFMS EasyVFR\">" "" "A Midsummer Night's Dream" "";

XMLDocument doc;
doc.Parse(xml);

XMLElement* titleElement = doc.FirstChildElement("PLAY")->FirstChildElement("TITLE");
const char* title = titleElement->GetText();
Serial.printf("Name of play (1): %s\n", title);

`

The file is exported from a navigator so I have no control over that. The line in the XML file that causes the crash is the <gpx ...> line (I added it to the sample xml to test) It crashes when calling XMLElement* titleElement = doc.FirstChildElement("PLAY")->FirstChildElement("TITLE");