static int sk_nextaddr(SockAddr addr)
{
#ifndef NO_IPV6
- if (addr->ai->ai_next) {
+ if (addr->ai && addr->ai->ai_next) {
addr->ai = addr->ai->ai_next;
addr->family = addr->ai->ai_family;
return TRUE;
goto ret;
}
+ cloexec(s);
+
if (sock->oobinline) {
int b = TRUE;
setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (void *) &b, sizeof(b));
return (Socket) ret;
}
+ cloexec(s);
+
ret->oobinline = 0;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
else
*canonicalname = dupstr(ret->hostname);
#ifndef NO_IPV6
- ret->ais = NULL;
+ ret->ai = ret->ais = NULL;
#else
ret->addresses = NULL;
+ ret->curraddr = ret->naddresses = 0;
#endif
return ret;
}