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:
parent
e29481ad14
commit
12ba2d58c3
@ -776,24 +776,26 @@ hostent_test_getaddrinfo_eq(struct hostent *he, void *mdata __unused)
|
|||||||
rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
|
rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
printf("not ok - shouldn't have been resolved\n");
|
printf("not ok - shouldn't have been resolved\n");
|
||||||
return (-1);
|
rv = -1;
|
||||||
}
|
} else
|
||||||
|
rv = 0;
|
||||||
} else {
|
} else {
|
||||||
rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
|
rv = getaddrinfo(he->h_name, NULL, &hints, &ai);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
printf("not ok - should have been resolved\n");
|
printf("not ok - should have been resolved\n");
|
||||||
return (-1);
|
rv = -1;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = is_hostent_equal(he, ai);
|
rv = is_hostent_equal(he, ai);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
printf("not ok - addrinfo and hostent are not equal\n");
|
printf("not ok - addrinfo and hostent are not equal\n");
|
||||||
return (-1);
|
rv = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
return (0);
|
if (ai != NULL)
|
||||||
|
freeaddrinfo(ai);
|
||||||
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user