diff --git a/tinyxml2.cpp b/tinyxml2.cpp index edf714d..3f45d1a 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -75,10 +75,12 @@ distribution. const int required = _vsnprintf(str, len, format, va); delete[] str; if ( required != -1 ) { + TIXMLASSERT( required >= 0 ); len = required; break; } } + TIXMLASSERT( len >= 0 ); return len; } #endif @@ -90,6 +92,7 @@ distribution. inline int TIXML_VSCPRINTF( const char* format, va_list va ) { int len = vsnprintf( 0, 0, format, va ); + TIXMLASSERT( len >= 0 ); return len; } #define TIXML_SSCANF sscanf @@ -2105,9 +2108,10 @@ void XMLPrinter::Print( const char* format, ... ) vfprintf( _fp, format, va ); } else { - int len = TIXML_VSCPRINTF( format, va ); + const int len = TIXML_VSCPRINTF( format, va ); // Close out and re-start the va-args va_end( va ); + TIXMLASSERT( len >= 0 ); va_start( va, format ); TIXMLASSERT( _buffer.Size() > 0 && _buffer[_buffer.Size() - 1] == 0 ); char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator.