Fix memory leak when there are no network interfaces or an error occurs.
This commit is contained in:
@@ -149,12 +149,13 @@ get_net_ifs(char **addrinfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num_interfaces == 0)
|
if (num_interfaces == 0)
|
||||||
debug_return_int(0);
|
goto done;
|
||||||
ailen = num_interfaces * 2 * INET6_ADDRSTRLEN;
|
ailen = num_interfaces * 2 * INET6_ADDRSTRLEN;
|
||||||
if ((cp = malloc(ailen)) == NULL) {
|
if ((cp = malloc(ailen)) == NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"unable to allocate memory");
|
"unable to allocate memory");
|
||||||
debug_return_int(-1);
|
num_interfaces = -1;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
*addrinfo = cp;
|
*addrinfo = cp;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user