mirror of https://github.com/AxioDL/tinyxml2.git
Merge pull request #328 from Dmitry-Me/firstCheckThenConvert
First check, then convert
This commit is contained in:
commit
e5e5541af6
|
@ -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 ) {
|
||||||
|
|
Loading…
Reference in New Issue