diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-06-10 07:45:18 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-06-10 07:45:18 +0000 |
commit | 06120d793a3ae31f8f510f220c8a0a8e23b6a177 (patch) | |
tree | e575c19a14531eb7ffbdc3d91e2afd605c21d11b /sysdeps | |
parent | 54c924656eb5f55b7a6e95bf6c31b6f3bc1e09dc (diff) | |
download | glibc-06120d793a3ae31f8f510f220c8a0a8e23b6a177.tar.gz glibc-06120d793a3ae31f8f510f220c8a0a8e23b6a177.tar.xz glibc-06120d793a3ae31f8f510f220c8a0a8e23b6a177.zip |
Update.
2003-06-10 Ulrich Drepper <drepper@redhat.com> * sysdeps/posix/getaddrinfo.c (getaddrinfo): Don't leak memory from getifaddr calls.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/posix/getaddrinfo.c | 11 |
1 files changed, 6 insertions, 5 deletions
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); |