Procházet zdrojové kódy

Merge pull request #150 from danmar/master

Fixed issue 147 (XMLDocument::LoadFile() may crash on non-regular file)
Lee Thomason před 12 roky
rodič
revize
2ece2f1690
1 změnil soubory, kde provedl 7 přidání a 0 odebrání
  1. 7 0
      tinyxml2.cpp

+ 7 - 0
tinyxml2.cpp

@@ -1639,6 +1639,13 @@ XMLError XMLDocument::LoadFile( FILE* fp )
 {
     Clear();
 
+    fseek( fp, 0, SEEK_SET );
+    fgetc( fp );
+    if ( ferror( fp ) != 0 ) {
+        SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
+        return _errorID;
+    }
+
     fseek( fp, 0, SEEK_END );
     size_t size = ftell( fp );
     fseek( fp, 0, SEEK_SET );