From 3788c654838f52499e8f2d63cad39ecc8f23bde5 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 2 Feb 2019 13:55:30 -0700 Subject: [PATCH] Fix memory leak when there are no network interfaces or an error occurs. --- src/net_ifs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; -- 2.50.1