fix: free args if expr is invalid

This commit is contained in:
Renge 2022-04-15 21:24:56 -04:00
parent e27119ba17
commit 64073b2490

View File

@ -341,9 +341,17 @@ int jobs_run(PIPELINE *pline) {
char **args = jobs_get_args(pline->commands->args);
// run command
if (execvp(args[0], args) == -1)
if (execvp(args[0], args) == -1) {
char **char_ptr = args;
while (*char_ptr)
{
free(*char_ptr);
char_ptr ++;
}
free(args);
exit(-1);
}
}
else {
// Leader process