Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash (pointer deref) in StrPair::GetStr() #659

Closed
weblkle opened this issue Feb 20, 2018 · 2 comments
Closed

Crash (pointer deref) in StrPair::GetStr() #659

weblkle opened this issue Feb 20, 2018 · 2 comments

Comments

@weblkle
Copy link

weblkle commented Feb 20, 2018

Some invalid (and unescaped) characters in the XMLText element are causing a crash when invoking GetText().
Here is a sample xml:
<root><Child Level=\"50\" Time=\"1518637009\">Valid characters, Not valid characters - €SÞ&#x0C-ung done</Child></root>

And some basic code parsing it:

int main(int argc, char* argv[])
{
    printf("Hello tinyxml2\n");

    const char* str_xml = "<root><Child Level=\"50\" Time=\"1518637009\">Valid characters, Not valid characters - €SÞ&#x0C-ung done</Child></root>";
    printf("Parsing:\n%s\n", str_xml);
    tinyxml2::XMLDocument doc;
    tinyxml2::XMLError rc = doc.Parse(str_xml);
    printf("Text parse result: %d\n", rc);
    if (rc != tinyxml2::XML_NO_ERROR)
        return rc;

    tinyxml2::XMLElement* elem = doc.FirstChildElement();
    if (!elem) return -1;

    elem = elem->FirstChildElement();
    const char* text = elem->GetText();

    printf("\nGetText()\n%s\n", text);
}

This potentially could be resolved with #255 (optional entity parsing). I know the characters are not valid and CData should be used, but it should probably not crash.

@leethomason
Copy link
Owner

As I run it, it works. I suspect the crash is that TinyXML-2 interprets everything as UTF-8, but printf/console isn't.

That said I wouldn't be at all surprised if there is a crasher in that code. I just can't reproduce it with this sample.

@weblkle
Copy link
Author

weblkle commented May 10, 2018

This was an issue with 2.1, which clearly was very outdated when I wrote it up originally. Sorry. And Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants