svn commit: r319054 - head/lib/libc/tests/nss
Ngie Cooper
ngie at FreeBSD.org
Sun May 28 07:40:44 UTC 2017
Author: ngie
Date: Sun May 28 07:40:42 2017
New Revision: 319054
URL: https://svnweb.freebsd.org/changeset/base/319054
Log:
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
Modified:
head/lib/libc/tests/nss/gethostby_test.c
Modified: head/lib/libc/tests/nss/gethostby_test.c
==============================================================================
--- head/lib/libc/tests/nss/gethostby_test.c Sun May 28 07:40:09 2017 (r319053)
+++ head/lib/libc/tests/nss/gethostby_test.c Sun May 28 07:40:42 2017 (r319054)
@@ -776,24 +776,26 @@ hostent_test_getaddrinfo_eq(struct hoste
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
More information about the svn-src-head
mailing list