mirror of https://github.com/AxioDL/tinyxml2.git
Asserts for formatted output length
This commit is contained in:
parent
78fca3db83
commit
1d32e586d5
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue