public: explicitly cast chars to bytes in ctype functions

This commit is contained in:
Alibek Omarov
2026-04-28 09:49:32 +05:00
parent f91e5a7647
commit ec8059173d
2 changed files with 10 additions and 4 deletions

View File

@@ -929,12 +929,12 @@ void COM_TrimSpace( char *dst, const char *src, size_t size )
return;
// remove spaces from the start
for( ; *src && isspace( *src ); src++ );
for( ; *src && isspace((byte)*src ); src++ );
int len = Q_strlen( src );
// remove spaces from the end
for( ; len > 0 && isspace( src[len - 1] ); len-- );
for( ; len > 0 && isspace((byte)src[len - 1] ); len-- );
if( len > 0 )
{

View File

@@ -170,9 +170,15 @@ static inline qboolean Q_istype( const char *str, int (*istype)( int c ))
{
if( likely( str && *str ))
{
while( istype( *str )) str++;
if( !*str ) return true;
// a1ba: explicitly cast char to unsigned char to not trigger UB
// in ctype functions
while( istype((byte)*str ))
str++;
if( !*str )
return true;
}
return false;
}