Fix a probably harmless uninitialised memory access.

This commit is contained in:
Sam Hocevar 2016-02-08 02:49:24 +01:00
parent c92c0cf4bb
commit a259a67e2d

View File

@ -605,14 +605,6 @@ static void selectPass(void) {
}
}
select(maxfd + 1, readfds, writefds, 0, 0);
for (int i = 0; i < seTotal; ++i) {
ServerInfo *srv = &seInfo[i];
if (srv->fd != INVALID_SOCKET) {
if (FD_ISSET_EXT(srv->fd, readfds)) {
handleAccept(srv);
}
}
}
for (int i = 0; i < coTotal; ++i) {
ConnectionInfo *cnx = &coInfo[i];
if (cnx->remote.fd != INVALID_SOCKET) {
@ -636,6 +628,15 @@ static void selectPass(void) {
}
}
}
/* Handle servers last because handleAccept() may modify coTotal */
for (int i = 0; i < seTotal; ++i) {
ServerInfo *srv = &seInfo[i];
if (srv->fd != INVALID_SOCKET) {
if (FD_ISSET_EXT(srv->fd, readfds)) {
handleAccept(srv);
}
}
}
}
static void handleRead(ConnectionInfo *cnx, Socket *socket, Socket *other_socket)