diff options
| author | salad <fmoenne-@student.le-101.fr> | 2020-04-28 17:35:37 +0200 | 
|---|---|---|
| committer | salad <fmoenne-@student.le-101.fr> | 2020-04-28 17:35:37 +0200 | 
| commit | 54d9c42870ba7b7c3380c146d549d9173e68d718 (patch) | |
| tree | 69ff746c6817b5f19b9d3760921589215179a12f | |
| parent | sneaky segv, onto backslashes (diff) | |
| download | 42-minishell-54d9c42870ba7b7c3380c146d549d9173e68d718.tar.gz 42-minishell-54d9c42870ba7b7c3380c146d549d9173e68d718.tar.bz2 42-minishell-54d9c42870ba7b7c3380c146d549d9173e68d718.tar.xz 42-minishell-54d9c42870ba7b7c3380c146d549d9173e68d718.tar.zst 42-minishell-54d9c42870ba7b7c3380c146d549d9173e68d718.zip | |
ptin de invalid read
Diffstat (limited to '')
| -rw-r--r-- | libft/Makefile | 2 | ||||
| -rw-r--r-- | src/ft_m_loop.c | 9 | 
2 files changed, 8 insertions, 3 deletions
| diff --git a/libft/Makefile b/libft/Makefile index 858e90b..85f063d 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -121,7 +121,7 @@ OS			= $(shell uname)  #-------------------------------- Compiler ------------------------------------#  #==============================================================================#  ifeq (${OS}, Linux) -	CC		= gcc +	CC		= clang  else  	CC		= clang  endif 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*/ | 
