From: Todd C. Miller Date: Sat, 2 Feb 2019 20:55:30 +0000 (-0700) Subject: Fix memory leak when there are no network interfaces or an error occurs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3788c654838f52499e8f2d63cad39ecc8f23bde5;p=sudo Fix memory leak when there are no network interfaces or an error occurs. --- diff --git a/src/net_ifs.c b/src/net_ifs.c index f95cf4d61..82610d8ed 100644 --- a/src/net_ifs.c +++ b/src/net_ifs.c @@ -149,12 +149,13 @@ get_net_ifs(char **addrinfo) } } if (num_interfaces == 0) - debug_return_int(0); + goto done; ailen = num_interfaces * 2 * INET6_ADDRSTRLEN; if ((cp = malloc(ailen)) == NULL) { sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, "unable to allocate memory"); - debug_return_int(-1); + num_interfaces = -1; + goto done; } *addrinfo = cp;