diff --git a/unix/uxnet.c b/unix/uxnet.c index 730f1fa7..75f809d2 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -1351,7 +1351,7 @@ static int net_select_result(int fd, int event) int err = errno; if (s->addr) { plug_log(s->plug, 1, s->addr, s->port, strerror(err), err); - while (s->addr && sk_nextaddr(s->addr, &s->step)) { + while (err && s->addr && sk_nextaddr(s->addr, &s->step)) { err = try_connect(s); } } diff --git a/windows/winnet.c b/windows/winnet.c index b4264def..72360639 100644 --- a/windows/winnet.c +++ b/windows/winnet.c @@ -1580,7 +1580,7 @@ int select_result(WPARAM wParam, LPARAM lParam) if (s->addr) { plug_log(s->plug, 1, s->addr, s->port, winsock_error_string(err), err); - while (s->addr && sk_nextaddr(s->addr, &s->step)) { + while (err && s->addr && sk_nextaddr(s->addr, &s->step)) { err = try_connect(s); } }