public: add buffer size parameter to COM_RemoveLineFeed

This commit is contained in:
Alibek Omarov 2024-05-15 03:06:57 +03:00
parent 3917c2589d
commit 758c908d5a
3 changed files with 6 additions and 6 deletions

View file

@ -645,14 +645,14 @@ void COM_ReplaceExtension( char *path, const char *extension, size_t size )
COM_RemoveLineFeed COM_RemoveLineFeed
============ ============
*/ */
void COM_RemoveLineFeed( char *str ) void COM_RemoveLineFeed( char *str, size_t bufsize )
{ {
while( *str != '\0' ) size_t i;
for( i = 0; i < bufsize && *str != '\0'; i++, str++ )
{ {
if( *str == '\r' || *str == '\n' ) if( *str == '\r' || *str == '\n' )
*str = '\0'; *str = '\0';
++str;
} }
} }

View file

@ -86,7 +86,7 @@ void COM_ReplaceExtension( char *path, const char *extension, size_t size );
void COM_ExtractFilePath( const char *path, char *dest ); void COM_ExtractFilePath( const char *path, char *dest );
const char *COM_FileWithoutPath( const char *in ); const char *COM_FileWithoutPath( const char *in );
void COM_StripExtension( char *path ); void COM_StripExtension( char *path );
void COM_RemoveLineFeed( char *str ); void COM_RemoveLineFeed( char *str, size_t bufsize );
void COM_FixSlashes( char *pname ); void COM_FixSlashes( char *pname );
void COM_PathSlashFix( char *path ); void COM_PathSlashFix( char *path );
char COM_Hex2Char( uint8_t hex ); char COM_Hex2Char( uint8_t hex );

View file

@ -79,7 +79,7 @@ qboolean LoadActivityList( const char *appname )
return false; return false;
} }
COM_RemoveLineFeed( buf ); COM_RemoveLineFeed( buf, sizeof( buf ));
activity_names[activity_count - 1] = strdup( buf ); activity_names[activity_count - 1] = strdup( buf );