2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Fix memory leaks in resolve_editor() in the error path.

Coverity CID 104109, 104110
This commit is contained in:
Todd C. Miller
2016-05-06 09:23:22 -06:00
parent 61c53c8e66
commit b4cb1c0a1f

View 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);
}
}