]> granicus.if.org Git - sudo/commitdiff
Fix memory leak when there are no network interfaces or an error occurs.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Sat, 2 Feb 2019 20:55:30 +0000 (13:55 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Sat, 2 Feb 2019 20:55:30 +0000 (13:55 -0700)
src/net_ifs.c

index f95cf4d61de014776b28ed866089efff74ddc0cf..82610d8edfabdb79421c8c7f7b874bc7a53b7fd6 100644 (file)
@@ -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;