From 6b2d24de2c672476ae2591d28b82ff747d42a101 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Sat, 16 Mar 2002 09:00:44 +0000 Subject: [PATCH] Make sure that freeaddrinfo is called on all code paths leading away from a call to getaddrinfo. (Dave Dykstra) <20011219085021.A23107@lucent.com> --- NEWS | 3 +++ socket.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 33fb2d76..e898557a 100644 --- 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.) diff --git a/socket.c b/socket.c index acf6234b..15dea8b8 100644 --- 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; } -- 2.34.1