]> granicus.if.org Git - sudo/commitdiff
Fix memory leaks in resolve_editor() in the error path.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 6 May 2016 15:23:22 +0000 (09:23 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 6 May 2016 15:23:22 +0000 (09:23 -0600)
Coverity CID 104109, 104110

plugins/sudoers/editor.c

index 6ef426186a8f0a8aedd3b20a6cbd1c4f0fb63a85..e5852862b802af2c1127535f61e9b389e637f276 100644 (file)
@@ -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);
        }
     }