sprintf -> snprintf to silence some compiler warnings

This commit is contained in:
Chris Morgan 2023-01-21 18:39:51 +00:00 committed by Mark Roszko
parent df4f9d4c94
commit 2b128c79f2
1 changed files with 4 additions and 4 deletions

View File

@ -200,7 +200,7 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext )
{
unsigned int code = c;
char buffer[16];
sprintf( buffer, "\\\\u%4.4X", code );
snprintf( buffer, sizeof(buffer), "\\\\u%4.4X", code );
converted += buffer;
}
else
@ -1128,7 +1128,7 @@ std::string UIDouble2Str( double aValue )
{
// For these small values, %f works fine,
// and %g gives an exponent
len = sprintf( buf, "%.16f", aValue );
len = snprintf( buf, sizeof(buf), "%.16f", aValue );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
@ -1142,8 +1142,8 @@ std::string UIDouble2Str( double aValue )
{
// For these values, %g works fine, and sometimes %f
// gives a bad value (try aValue = 1.222222222222, with %.16f format!)
len = sprintf( buf, "%.10g", aValue );
len = snprintf( buf, sizeof(buf), "%.10g", aValue );
}
return std::string( buf, len );
}
}