hostent_test_getaddrinfo_eq(..): call freeaddrinfo on ai when done

This plugs a leak of memory allocated via getaddrinfo.

MFC after:	1 week
Reported by:	Coverity
CID:		1346866
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Enji Cooper 2017-05-28 07:40:42 +00:00
parent 9ecc1abca3
commit ae442ee64a

View File

@ -776,24 +776,26 @@ hostent_test_getaddrinfo_eq(struct hostent *he, void *mdata __unused)
rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
if (rv == 0) {
printf("not ok - shouldn't have been resolved\n");
return (-1);
}
rv = -1;
} else
rv = 0;
} else {
rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
if (rv != 0) {
printf("not ok - should have been resolved\n");
return (-1);
rv = -1;
goto done;
}
rv = is_hostent_equal(he, ai);
if (rv != 0) {
printf("not ok - addrinfo and hostent are not equal\n");
return (-1);
rv = -1;
}
}
return (0);
done:
if (ai != NULL)
freeaddrinfo(ai);
return (rv);
}
static int