server/sws: fix asan warning on use of uninitialized variable

This commit is contained in:
Daniel Stenberg 2020-05-29 13:04:25 +02:00
parent 733a39a907
commit 6531d089e5
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
1 changed files with 5 additions and 1 deletions

View File

@ -2206,6 +2206,7 @@ int main(int argc, char *argv[])
fd_set output;
struct timeval timeout = {0, 250000L}; /* 250 ms */
curl_socket_t maxfd = (curl_socket_t)-1;
int active;
/* Clear out closed sockets */
for(socket_idx = num_sockets - 1; socket_idx >= 1; --socket_idx) {
@ -2253,6 +2254,7 @@ int main(int argc, char *argv[])
/* Timed out - try again */
continue;
}
active = rc; /* a positive number */
/* Check if the listening socket is ready to accept */
if(FD_ISSET(all_sockets[0], &input)) {
@ -2264,11 +2266,13 @@ int main(int argc, char *argv[])
if(CURL_SOCKET_BAD == msgsock)
goto sws_cleanup;
} while(msgsock > 0);
active--;
}
/* Service all connections that are ready */
for(socket_idx = 1; socket_idx < num_sockets; ++socket_idx) {
for(socket_idx = 1; (socket_idx < num_sockets) && active; ++socket_idx) {
if(FD_ISSET(all_sockets[socket_idx], &input)) {
active--;
if(got_exit_signal)
goto sws_cleanup;