ip: fixed memory leak

free the interface list before returning from the function
This commit is contained in:
Tobias Tschinkowitz 2018-05-20 15:53:48 +02:00 committed by Aaron Marcher
parent b640cc489b
commit 1cd8a7b510

View file

@ -31,6 +31,7 @@ ip(const char *iface, unsigned short sa_family)
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
if (!strcmp(ifa->ifa_name, iface) && if (!strcmp(ifa->ifa_name, iface) &&
(ifa->ifa_addr->sa_family == sa_family)) { (ifa->ifa_addr->sa_family == sa_family)) {
freeifaddrs(ifaddr);
if (s != 0) { if (s != 0) {
warn("getnameinfo: %s", gai_strerror(s)); warn("getnameinfo: %s", gai_strerror(s));
return NULL; return NULL;