From: Simon Tatham Date: Sat, 20 Dec 2014 16:54:28 +0000 (+0000) Subject: Add a missing freeaddrinfo() in Unix sk_newlistener. X-Git-Tag: 0.64~13 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=fe24f4dfba2aa2db270427bb3d1f7c6cb7f19221;hp=-c;p=PuTTY.git Add a missing freeaddrinfo() in Unix sk_newlistener. If we use getaddrinfo to translate the source IP address into a sockaddr, then we need to freeaddrinfo the returned data later. Patch due to Tim Kosse. --- fe24f4dfba2aa2db270427bb3d1f7c6cb7f19221 diff --git a/unix/uxnet.c b/unix/uxnet.c index c3002e43..235d6fd9 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -780,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; @@ -926,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);