Skip to content

Commit b6cb0c2

Browse files
committed
game: fix UB when reading mapcycle
1 parent 8acf608 commit b6cb0c2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

game/shared/multiplay_gamerules.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,12 +1151,14 @@ ConVarRef suitcharger( "sk_suitcharger" );
11511151

11521152
void StripChar(char *szBuffer, const char cWhiteSpace )
11531153
{
1154+
char *src, *dst;
11541155

1155-
while ( char *pSpace = strchr( szBuffer, cWhiteSpace ) )
1156+
for (src = dst = szBuffer; *src != '\0'; src++)
11561157
{
1157-
char *pNextChar = pSpace + sizeof(char);
1158-
V_strcpy( pSpace, pNextChar );
1158+
*dst = *src;
1159+
if (*dst != cWhiteSpace) dst++;
11591160
}
1161+
*dst = '\0';
11601162
}
11611163

11621164
void CMultiplayRules::GetNextLevelName( char *pszNextMap, int bufsize, bool bRandom /* = false */ )

0 commit comments

Comments
 (0)