Menu

STL String Error

Developer
Dave Cross
2007-05-23
2013-05-20
  • Dave Cross

    Dave Cross - 2007-05-23

    In TiXmlDocument::LoadFile() we read:
    bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
    {
        // There was a really terrifying little bug here. The code:
        //        value = filename
        // in the STL case, cause the assignment method of the std::string to
        // be called. What is strange, is that the std::string had the same
        // address as it's c_str() method, and so bad things happen. Looks
        // like a bug in the Microsoft STL implementation.
        // Add an extra string to avoid the crash.

    /*    TIXML_STRING filename( _filename );
        value = filename;

        // reading in binary mode so that tinyxml can normalize the EOL
        FILE* file = TiXmlFOpen( value.c_str (), "rb" );   

    What's wrong with the simple solution?

    bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
    {
        FILE* file = TiXmlFOpen( _filename, "rb" );   

     
    • Lee Thomason

      Lee Thomason - 2007-06-02

      Outdated comment - cleaned up in source.

      thanks!
      lee

       

Log in to post a comment.