fix: free args if expr is invalid
This commit is contained in:
parent
e27119ba17
commit
64073b2490
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user