]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Add a missing freeaddrinfo() in Unix sk_newlistener.
authorSimon Tatham <anakin@pobox.com>
Sat, 20 Dec 2014 16:54:28 +0000 (16:54 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 20 Dec 2014 17:00:01 +0000 (17:00 +0000)
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.

unix/uxnet.c

index c3002e4388ebc8bd50d58da45db53fbd599bf412..235d6fd97d039d3ed2f97167e68e4285935981ee 100644 (file)
@@ -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);