diff --git a/public/crtlib.c b/public/crtlib.c index 9c2b55e1..796f2ca2 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -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 ) { diff --git a/public/crtlib.h b/public/crtlib.h index f9a8b893..ae87aced 100644 --- a/public/crtlib.h +++ b/public/crtlib.h @@ -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; }