From: Todd C. Miller Date: Fri, 6 May 2016 15:23:22 +0000 (-0600) Subject: Fix memory leaks in resolve_editor() in the error path. X-Git-Tag: SUDO_1_8_17^2~101 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4cb1c0a1f0293c56b8421634fa0b5504d9dcd3b;p=sudo Fix memory leaks in resolve_editor() in the error path. Coverity CID 104109, 104110 --- diff --git a/plugins/sudoers/editor.c b/plugins/sudoers/editor.c index 6ef426186..e5852862b 100644 --- a/plugins/sudoers/editor.c +++ b/plugins/sudoers/editor.c @@ -81,6 +81,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files, if (nargv == NULL) { sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); free(editor); + free(editor_path); debug_return_str(NULL); } @@ -90,8 +91,10 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files, nargv[nargc] = strndup(cp, (size_t)(ep - cp)); if (nargv[nargc] == NULL) { sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); + free(editor_path); while (nargc--) free(nargv[nargc]); + free(nargv); debug_return_str(NULL); } }