Menu

Infinite loop, mem exhaustion on weird XML

marlonism
2005-05-04
2013-05-20
  • marlonism

    marlonism - 2005-05-04

    Hello,

    Sorry if this has been posted before.

    Anyway, when I load an XML file in TinyXML containing text that is "out-of-place", TinyXML will go into an infinite loop using 100% CPU and then will eventually exhaust virtual memory:

    TiXmlBase::SetCondenseWhiteSpace(false);
    TiXmlDocument xml;
    xml.Parse("<text><break/>This hangs</text>");

    It seems like the problem is in TiXmlElement::ReadValue() where an already advanced 'p' gets reset to the value of pWithWhiteSpace (which interestingly is not updated whenever p is updated)

    // here, p points to "This hangs</text>"
    // while pWithWhiteSpace still points to "<break/>This hangs</text>"
    p = textNode->Parse( pWithWhiteSpace, data, encoding );
    // but here, p goes back to "<break/>This hangs</text>", thus the infinite loop

    Any ideas?

    Thanks!

    --marlon

     
    • Lee Thomason

      Lee Thomason - 2005-05-05

      I posted a bug.
      lee

       
    • Lee Thomason

      Lee Thomason - 2005-06-21

      Fixed in CVS. When maintaining white space, TinyXml keeps 2 pointers - one for parsing that ignores white space, and one that keeps it. The "keep white space" pointer wasn't getting updated, and kept re-parsing the same tag.

      great bug - thanks again.
      lee

       

Log in to post a comment.