fix memleak on background cmd error

- src must be free after join_args()
- wordfree must bee used after wordexp
This commit is contained in:
ael-code 2018-06-26 12:53:47 +02:00
parent af0f0375ef
commit 4550cb2b3e
No known key found for this signature in database
GPG Key ID: 3390538CF7E96023

View File

@ -62,8 +62,11 @@ struct cmd_results *output_cmd_background(int argc, char **argv) {
wordexp_t p;
char *src = join_args(argv, j);
if (wordexp(src, &p, 0) != 0 || p.we_wordv[0] == NULL) {
return cmd_results_new(CMD_INVALID, "output",
"Invalid syntax (%s).", src);
struct cmd_results *cmd_res = cmd_results_new(CMD_INVALID, "output",
"Invalid syntax (%s)", src);
free(src);
wordfree(&p);
return cmd_res;
}
free(src);
src = p.we_wordv[0];