From 72801b8b205b3bdc05fad696034b2f902b817b58 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 7 May 2015 09:41:39 +0300 Subject: [PATCH] First check, then convert --- tinyxml2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 03ce1b9..6e1985b 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1852,12 +1852,12 @@ XMLError XMLDocument::LoadFile( FILE* fp ) return _errorID; } - const size_t size = filelength; - if ( size == 0 ) { + if ( filelength == 0 ) { SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); return _errorID; } + const size_t size = filelength; _charBuffer = new char[size+1]; size_t read = fread( _charBuffer, 1, size, fp ); if ( read != size ) {