fix: env filler variable do not exist cause invalid read

This commit is contained in:
Camille Chauvet 2023-02-17 13:42:53 +01:00
parent 6090784c02
commit 7bec120312

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 16:29:08 by cchauvet #+# #+# */ /* Created: 2023/02/16 16:29:08 by cchauvet #+# #+# */
/* Updated: 2023/02/16 17:49:03 by cchauvet ### ########.fr */ /* Updated: 2023/02/17 13:41:51 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -61,7 +61,6 @@ char *ft_env_filler(t_list **env, const char *str)
if (value == NULL) if (value == NULL)
return (NULL); return (NULL);
temp = ft_strreplace(out, value, i, y); temp = ft_strreplace(out, value, i, y);
i = i + ft_strlen(value) - 1;
free(out); free(out);
if (temp == NULL) if (temp == NULL)
{ {
@ -70,6 +69,7 @@ char *ft_env_filler(t_list **env, const char *str)
} }
out = temp; out = temp;
} }
if (out[i] != '\0')
i++; i++;
} }
return (out); return (out);