Make sure that freeaddrinfo is called on all code paths leading away
authorMartin Pool <mbp@samba.org>
Sat, 16 Mar 2002 09:00:44 +0000 (09:00 +0000)
committerMartin Pool <mbp@samba.org>
Sat, 16 Mar 2002 09:00:44 +0000 (09:00 +0000)
from a call to getaddrinfo.  (Dave Dykstra)
<20011219085021.A23107@lucent.com>

NEWS
socket.c

diff --git a/NEWS b/NEWS
index 33fb2d7..e898557 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,3 +11,6 @@ rsync changes since last release
   BUG FIXES:
 
     * Fix test suite on Solaris.  (Jos Backus)
+
+    * Fix minor memory leak in socket code.  (Dave Dykstra, Martin
+      Pool.)
index acf6234..15dea8b 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -119,17 +119,17 @@ int try_bind_local(int s,
                return -1;
        }
 
-       /* FIXME: Call freeaddrinfo() on all return paths! */
-
        for (r = bres_all; r; r = r->ai_next) {
                if (bind(s, r->ai_addr, r->ai_addrlen) == -1)
                        continue;
+               freeaddrinfo(bres_all);
                return s;
        }
 
        /* no error message; there might be some problem that allows
         * creation of the socket but not binding, perhaps if the
         * machine has no ipv6 address of this name. */
+       freeaddrinfo(bres_all);
        return -1;
 }
 
@@ -332,7 +332,7 @@ static int open_socket_in(int type, int port, const char *bind_address,
                        continue;
                }
 
-               /* FIXME: Call freeaddrinfo? */
+               freeaddrinfo(all_ai);
                return s;
        }