Before receiving game list from server, clear old games from list, and don't receive more than there are room for in the array.

master
Cyp 2010-07-22 14:07:34 +02:00
parent 9a05862fba
commit 1b811abcea
1 changed files with 4 additions and 1 deletions

View File

@ -2608,7 +2608,7 @@ BOOL NETfindGame(void)
&& socketReadReady(tcp_socket)
&& (result = readNoInt(tcp_socket, &gamesavailable, sizeof(gamesavailable))))
{
gamesavailable = ntohl(gamesavailable);
gamesavailable = MIN(ntohl(gamesavailable), ARRAY_SIZE(NetPlay.games));
}
else
{
@ -2631,6 +2631,9 @@ BOOL NETfindGame(void)
debug(LOG_NET, "receiving info on %u game(s)", (unsigned int)gamesavailable);
// Clear old games from list.
memset(NetPlay.games, 0x00, sizeof(NetPlay.games));
do
{
// Attempt to receive a game description structure