"Do not index an array out of bounds when displaying a chat message from another player with an invalid (unknown) dpid."

Thanks to gerard for the elaboration of the description. ;)

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7460 4a71c877-e1ca-e34f-864e-861f7616d084
master
Buginator 2009-05-18 03:57:21 +00:00 committed by Git SVN Gateway
parent 1ed583995a
commit e89dc5e8ec
1 changed files with 12 additions and 5 deletions

View File

@ -1109,12 +1109,19 @@ BOOL sendTextMessage(const char *pStr, BOOL all)
}
//This is for local display
for(i = 0; NetPlay.players[i].dpid != NetPlay.dpidPlayer; i++); //findplayer
sstrcat(display, NetPlay.players[i].name); // name
sstrcat(display, ": "); // seperator
sstrcat(display, pStr); // add message
for (i = 0; i < ARRAY_SIZE(NetPlay.players); ++i)
{
if (NetPlay.players[i].dpid == NetPlay.dpidPlayer)
{
sstrcat(display, NetPlay.players[i].name); // name
sstrcat(display, ": "); // seperator
sstrcat(display, pStr); // add message
addConsoleMessage(display, DEFAULT_JUSTIFY, selectedPlayer); // display
break;
}
}
addConsoleMessage(display, DEFAULT_JUSTIFY, selectedPlayer); // display
return true;
}