Browse Source

[fix] heredoc: change buffer size to 4. Free cause crashes.

Moul 2 years ago
parent
commit
2be30480f8
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/heredoc.c

+ 2 - 2
src/heredoc.c

@@ -85,7 +85,7 @@ char	*prompt_heredoc(t_e *e, char *txt, char *eof, int i)
 			txt = ft_strnew(0);
 		else
 		{
-			txt = ft_strjoinf(txt, ft_strjoinf(h->cmd, "\n", 1), 3);
+			txt = ft_strjoin(txt, ft_strjoinf(h->cmd, "\n", 1));
 			h->cmd = ft_strnew(0);
 		}
 		ft_putchar('>');
@@ -114,7 +114,7 @@ int		here_edition(t_e *h, int heredoc)
 	int		ret;
 
 	h->key = ft_strnew(4);
-	while ((ret = read(0, h->key, 1)) > 0)
+	while ((ret = read(0, h->key, 4)) > 0)
 	{
 		if (h->key[0] == 10)
 		{