diff --git a/resources/empty.xml b/resources/empty.xml new file mode 100644 index 0000000..e69de29 diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 1b9a419..3b38584 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1608,6 +1608,7 @@ XMLError XMLDocument::LoadFile( FILE* fp ) fseek( fp, 0, SEEK_SET ); if ( size == 0 ) { + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } diff --git a/xmltest.cpp b/xmltest.cpp index 2e056d1..231328e 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -1158,6 +1158,13 @@ int main( int argc, const char ** argv ) } + { + XMLDocument doc; + XMLError error = doc.LoadFile( "resources/empty.xml" ); + XMLTest( "Loading an empty file", XML_ERROR_EMPTY_DOCUMENT, error ); + } + + // ----------- Performance tracking -------------- { #if defined( _MSC_VER )