OSDN Git Service

Fix freeaddrinfo(NULL).
authorElliott Hughes <enh@google.com>
Fri, 9 Jan 2015 01:28:46 +0000 (17:28 -0800)
committerElliott Hughes <enh@google.com>
Fri, 9 Jan 2015 01:28:46 +0000 (17:28 -0800)
Bug: https://code.google.com/p/android/issues/detail?id=13228
Change-Id: I5e3b126d90d750a93ac0b8872198e50ba047e603

libc/dns/net/getaddrinfo.c
tests/netdb_test.cpp

index f0d522a..c73c085 100644 (file)
@@ -324,7 +324,11 @@ freeaddrinfo(struct addrinfo *ai)
 {
        struct addrinfo *next;
 
-       assert(ai != NULL);
+#if __ANDROID__
+       if (ai == NULL) return;
+#else
+       _DIAGASSERT(ai != NULL);
+#endif
 
        do {
                next = ai->ai_next;
index ab5b487..5660bbd 100644 (file)
 #include <sys/socket.h>
 #include <netinet/in.h>
 
+// https://code.google.com/p/android/issues/detail?id=13228
+TEST(netdb, freeaddrinfo_NULL) {
+  freeaddrinfo(NULL);
+}
+
 TEST(netdb, getaddrinfo_NULL_host) {
   // It's okay for the host argument to be NULL, as long as service isn't.
   addrinfo* ai = NULL;