X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fuxnet.c;h=235d6fd97d039d3ed2f97167e68e4285935981ee;hb=f004bcca17a789356c32527a396b68b71a773db2;hp=1fe78436115878ce98174c6d5d9de8e158db4208;hpb=8da4fa506389910599c59b87ba1b799efd6d3ae1;p=PuTTY.git diff --git a/unix/uxnet.c b/unix/uxnet.c index 1fe78436..235d6fd9 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -126,9 +126,12 @@ struct SockAddr_tag { (addr)->superfamily == UNIX ? AF_UNIX : \ (step).ai ? (step).ai->ai_family : AF_INET) #else +/* Here we gratuitously reference 'step' to avoid gcc warnings about + * 'set but not used' when compiling -DNO_IPV6 */ #define SOCKADDR_FAMILY(addr, step) \ ((addr)->superfamily == UNRESOLVED ? AF_UNSPEC : \ - (addr)->superfamily == UNIX ? AF_UNIX : AF_INET) + (addr)->superfamily == UNIX ? AF_UNIX : \ + (step).curraddr ? AF_INET : AF_INET) #endif /* @@ -777,7 +780,7 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i { int s; #ifndef NO_IPV6 - struct addrinfo hints, *ai; + struct addrinfo hints, *ai = NULL; char portstr[6]; #endif union sockaddr_union u; @@ -923,6 +926,12 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i } retcode = bind(s, &addr->sa, addrlen); + +#ifndef NO_IPV6 + if (ai) + freeaddrinfo(ai); +#endif + if (retcode < 0) { close(s); ret->error = strerror(errno);