summaryrefslogtreecommitdiffstats
path: root/src/ft_m_loop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_m_loop.c')
-rw-r--r--src/ft_m_loop.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ft_m_loop.c b/src/ft_m_loop.c
index 6a05dd6..7c6259c 100644
--- a/src/ft_m_loop.c
+++ b/src/ft_m_loop.c
@@ -26,8 +26,11 @@ uint8_t
int8_t gnl;
char *prog;
char *buf;
+ char *fin;
- if (!(prog = malloc((quote - line) * sizeof(char))))
+ 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);
@@ -39,9 +42,11 @@ uint8_t
ft_sprintf(buf + ft_strlen(buf), "\n%s", line);
}
buf = ft_strtrim(buf, "\"'");
- ft_p_line(ft_strjoin(prog, buf), msh);
+ fin = ft_strjoin(prog, buf);
+ ft_p_line(fin, msh);
ft_memdel((void*)&line);
ft_memdel((void*)&buf);
+ ft_memdel((void*)&fin);
ft_e_lcom(msh);
ft_lcom_clear(&msh->curr);
return (1); /*got second quote, keep going*/