Allow freeaddrinfo(NULL) (XCC)
authorXiao Jia <stfairy@gmail.com>
Tue, 13 Oct 2015 23:57:00 +0000 (16:57 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 14 Oct 2015 21:14:45 +0000 (17:14 -0400)
On both glibc and uclibc, freeaddrinfo(NULL) is safe, though there is no
explicit requirement for that in the spec:
http://pubs.opengroup.org/onlinepubs/009695399/functions/getaddrinfo.html

So let's change freeaddrinfo() to handle that case.

Rebuild glibc.

Signed-off-by: Xiao Jia <stfairy@gmail.com>
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/getaddrinfo.c

index 875573c..b9632d2 100644 (file)
@@ -217,11 +217,13 @@ libc_hidden_def(getaddrinfo)
 
 void freeaddrinfo(struct addrinfo *ai)
 {
-       struct addrinfo *next = ai->ai_next;
+       struct addrinfo *next;
+       if (!ai)
+               return;
        free(ai->ai_addr);
        free(ai->ai_canonname);
+       next = ai->ai_next;
        free(ai);
-       if (next)
-               freeaddrinfo(next);
+       freeaddrinfo(next);
 }
 libc_hidden_def(freeaddrinfo)