Merge "Fix freeaddrinfo(NULL)."

This commit is contained in:
Elliott Hughes 2015-01-09 02:48:28 +00:00 committed by Gerrit Code Review
commit 8623dc7547
2 changed files with 10 additions and 1 deletions

View 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;

View file

@ -23,6 +23,11 @@
#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;