mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r14759) -Fix (r14730): tab completion causing out-of-bounds read.
This commit is contained in:
parent
ee952b10d9
commit
e626e07bd3
@ -127,7 +127,7 @@ static inline bool IsValidNetworkClientSocketIndex(ClientIndex index)
|
|||||||
return (uint)index < GetNetworkClientSocketPoolSize() && GetNetworkClientSocket(index)->IsValid();
|
return (uint)index < GetNetworkClientSocketPoolSize() && GetNetworkClientSocket(index)->IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = (start < GetNetworkClientSocketPoolSize() ? GetNetworkClientSocket(start) : NULL); d != NULL; d = (d->index + 1U < GetNetworkClientSocketPoolSize()) ? GetNetworkClientSocket(d->index + 1U) : NULL) if (d->IsValid())
|
#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = GetNetworkClientSocket(start); d != NULL; d = (d->index + 1U < GetNetworkClientSocketPoolSize()) ? GetNetworkClientSocket(d->index + 1U) : NULL) if (d->IsValid())
|
||||||
#define FOR_ALL_CLIENT_SOCKETS(d) FOR_ALL_CLIENT_SOCKETS_FROM(d, 0)
|
#define FOR_ALL_CLIENT_SOCKETS(d) FOR_ALL_CLIENT_SOCKETS_FROM(d, 0)
|
||||||
|
|
||||||
typedef NetworkClientSocket NetworkTCPSocketHandler;
|
typedef NetworkClientSocket NetworkTCPSocketHandler;
|
||||||
|
@ -300,12 +300,14 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
|
|||||||
|
|
||||||
/* First, try clients */
|
/* First, try clients */
|
||||||
if (*item < MAX_CLIENT_SLOTS) {
|
if (*item < MAX_CLIENT_SLOTS) {
|
||||||
/* Skip inactive clients */
|
if (*item + 1 < GetNetworkClientInfoPoolSize()) {
|
||||||
NetworkClientInfo *ci;
|
/* Skip inactive clients */
|
||||||
FOR_ALL_CLIENT_INFOS_FROM(ci, *item + 1) break;
|
NetworkClientInfo *ci;
|
||||||
if (ci != NULL) {
|
FOR_ALL_CLIENT_INFOS_FROM(ci, *item + 1) break;
|
||||||
*item = ci->index;
|
if (ci != NULL) {
|
||||||
return ci->client_name;
|
*item = ci->index;
|
||||||
|
return ci->client_name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*item = MAX_CLIENT_SLOTS;
|
*item = MAX_CLIENT_SLOTS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user