libreplace: fix silly crashbug in getifaddrs_test().
authorMichael Adam <obnox@samba.org>
Fri, 29 Feb 2008 01:22:02 +0000 (02:22 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 29 Feb 2008 08:31:50 +0000 (09:31 +0100)
Michael
(cherry picked from commit 523626908d25f974fd1ae6d7306b1d4bc8414162)

source/lib/replace/test/getifaddrs.c

index 4455462193db9bb6cefe2dd539c9fa01762c085b..c78c9b545e2281f704a255e524139a2299ec7645 100644 (file)
@@ -51,9 +51,11 @@ static const char *format_sockaddr(struct sockaddr *addr,
 int getifaddrs_test(void)
 {
        struct ifaddrs *ifs = NULL;
+       struct ifaddrs *ifs_head = NULL;
        int ret;
 
        ret = getifaddrs(&ifs);
+       ifs_head = ifs;
        if (ret != 0) {
                fprintf(stderr, "getifaddrs() failed: %s\n", strerror(errno));
                return 1;
@@ -90,7 +92,7 @@ int getifaddrs_test(void)
                ifs = ifs->ifa_next;
        }
 
-       freeifaddrs(ifs);
+       freeifaddrs(ifs_head);
 
        return 0;
 }