Merge pull request #328 from Dmitry-Me/firstCheckThenConvert

First check, then convert
This commit is contained in:
Lee Thomason 2015-05-07 13:54:31 -07:00
commit e5e5541af6
1 changed files with 2 additions and 2 deletions

View File

@ -1852,12 +1852,12 @@ XMLError XMLDocument::LoadFile( FILE* fp )
return _errorID; return _errorID;
} }
const size_t size = filelength; if ( filelength == 0 ) {
if ( size == 0 ) {
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
return _errorID; return _errorID;
} }
const size_t size = filelength;
_charBuffer = new char[size+1]; _charBuffer = new char[size+1];
size_t read = fread( _charBuffer, 1, size, fp ); size_t read = fread( _charBuffer, 1, size, fp );
if ( read != size ) { if ( read != size ) {