2 Commits d98c14b92f ... 7f4e84e72e

Author SHA1 Message Date
  Moul 7f4e84e72e [fix] free 'p' after var usage. 2 years ago
  Moul b40f60c96f [fix] mallocation was only done for cmds and not for 'NULL'. 2 years ago
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/pipe_exec.c

+ 2 - 2
src/pipe_exec.c

@@ -9,7 +9,7 @@
 void	launch_pipes(t_e *e, t_pipe *p, t_pr **t)
 {
 	p->i = -1;
-	p->cmd_opt = (char***)malloc(sizeof(char**) * (p->nbr + 1));
+	p->cmd_opt = (char***)malloc(sizeof(char**) * (p->nbr + 2));
 	while (++p->i <= p->pnbr)
 	{
 		if (t[p->i]->itxt != NULL)
@@ -27,10 +27,10 @@ void	launch_pipes(t_e *e, t_pipe *p, t_pr **t)
 	free(p->cmd_pipe);
 	p->cmd_opt[p->i] = NULL;
 	free(p->fd);
-	free(p);
 	p->i = -1;
 	while (++p->i <= p->nbr)
 		wait(NULL);
+	free(p);
 }
 
 /*