summaryrefslogtreecommitdiffstats
path: root/src/ft_m_loop.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-04-28 18:37:12 +0200
committersalad <fmoenne-@student.le-101.fr>2020-04-28 18:37:12 +0200
commita4fb6efe7aa29fad4483ad31909afd67854fd464 (patch)
treed374d7c325f3852b719e617a2110bbc81bc58905 /src/ft_m_loop.c
parentptin de invalid read (diff)
download42-minishell-a4fb6efe7aa29fad4483ad31909afd67854fd464.tar.gz
42-minishell-a4fb6efe7aa29fad4483ad31909afd67854fd464.tar.bz2
42-minishell-a4fb6efe7aa29fad4483ad31909afd67854fd464.tar.xz
42-minishell-a4fb6efe7aa29fad4483ad31909afd67854fd464.tar.zst
42-minishell-a4fb6efe7aa29fad4483ad31909afd67854fd464.zip
nothing of value was lost
Diffstat (limited to '')
-rw-r--r--src/ft_m_loop.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ft_m_loop.c b/src/ft_m_loop.c
index 7c6259c..2280cfd 100644
--- a/src/ft_m_loop.c
+++ b/src/ft_m_loop.c
@@ -30,8 +30,6 @@ uint8_t
if (!(prog = ft_calloc(ft_strlen(line + 1), sizeof(char))))
return (0);
- if (!(fin = malloc((ft_strlen(prog) + ft_strlen(buf)) * sizeof(char))))
- return (0);
ft_memcpy(prog, line, (quote - line));
buf = ft_strdup(line + (quote - line) + 1);
gnl = 1;
@@ -42,14 +40,17 @@ uint8_t
ft_sprintf(buf + ft_strlen(buf), "\n%s", line);
}
buf = ft_strtrim(buf, "\"'");
+ if (!(fin = malloc((ft_strlen(prog) + ft_strlen(buf)) * sizeof(char))))
+ return (0);
fin = ft_strjoin(prog, buf);
ft_p_line(fin, msh);
ft_memdel((void*)&line);
ft_memdel((void*)&buf);
ft_memdel((void*)&fin);
+ ft_memdel((void*)&prog);
ft_e_lcom(msh);
ft_lcom_clear(&msh->curr);
- return (1); /*got second quote, keep going*/
+ return (1);
}
uint8_t