From 06120d793a3ae31f8f510f220c8a0a8e23b6a177 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 10 Jun 2003 07:45:18 +0000 Subject: Update. 2003-06-10 Ulrich Drepper * sysdeps/posix/getaddrinfo.c (getaddrinfo): Don't leak memory from getifaddr calls. --- sysdeps/posix/getaddrinfo.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 062d10849d..23f7122ae1 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -930,7 +930,7 @@ getaddrinfo (const char *name, const char *service, XXX We are using getifaddrs here which is more costly than it is really necessary. Once things are stable we will have a special function which performs the task with less overhead. */ - struct ifaddrs* ifa = NULL; + struct ifaddrs *ifa = NULL; if (getifaddrs (&ifa) != 0) /* Cannot get the interface list, very bad. */ @@ -939,14 +939,15 @@ getaddrinfo (const char *name, const char *service, bool seen_ipv4 = false; bool seen_ipv6 = false; - while (ifa != NULL) + struct ifaddrs *runp = ifa; + while (runp != NULL) { - if (ifa->ifa_addr->sa_family == PF_INET) + if (runp->ifa_addr->sa_family == PF_INET) seen_ipv4 = true; - else if (ifa->ifa_addr->sa_family == PF_INET6) + else if (runp->ifa_addr->sa_family == PF_INET6) seen_ipv6 = true; - ifa = ifa->ifa_next; + runp = runp->ifa_next; } (void) freeifaddrs (ifa); -- cgit 1.4.1