From b4cb1c0a1f0293c56b8421634fa0b5504d9dcd3b Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 6 May 2016 09:23:22 -0600 Subject: [PATCH] Fix memory leaks in resolve_editor() in the error path. Coverity CID 104109, 104110 --- plugins/sudoers/editor.c | 3 +++ 1 file changed, 3 insertions(+) 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); } } -- 2.40.0