Skip to content

Commit 91f7869

Browse files
committed
Fix off-by-two causing partial multibyte character truncation.
1 parent 5b27824 commit 91f7869

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,9 @@ static Bool TruncatePlayerNames(AsciiStringVec& playerNames, Int truncateAmount)
979979
}
980980

981981
// as the name is UTF-8, make sure we don't truncate part of a multibyte character
982-
while ((playerNames[lengthIndex[i].Index][lengthIndex[i].Length - truncateNameAmount - 1] & 0xC0) == 0x80) {
982+
while (lengthIndex[i].Length - truncateNameAmount >= MinimumNameLength
983+
&& (playerNames[lengthIndex[i].Index][lengthIndex[i].Length - truncateNameAmount + 1] & 0xC0) == 0x80)
984+
{
983985
++truncateNameAmount; // move back to the start of the multibyte character
984986
}
985987

0 commit comments

Comments
 (0)