Browse Source

[fix] correct segfault with '|'.

Moul 2 years ago
parent
commit
0123b092a2
2 changed files with 3 additions and 0 deletions
  1. 2 0
      src/pipe_exec.c
  2. 1 0
      tests.sh

+ 2 - 0
src/pipe_exec.c

@@ -15,6 +15,8 @@ void	launch_pipes(t_e *e, t_pipe *p, t_pr **t)
 		if (t[p->i]->itxt != NULL)
 		{
 			p->cmd_opt[p->i] = cmd_splitting(e, t[p->i]->itxt, ' ');
+			if (p->cmd_opt[p->i] == NULL)
+				break ;
 			remove_cotes(p->cmd_opt[p->i]);
 		}
 		handle_multi_piping(e, p, t[p->i]);

+ 1 - 0
tests.sh

@@ -65,6 +65,7 @@ tests=(
 "ls || cat" # Segfault
 "ls ||||||||| cat"
 "ls | | ls" # Segfault
+"|" # Segfault
 
 ## Redirections droite
 "ls > $tmpf ; cat $tmpf ; rm $tmpf" # simple