From 0f61c048ae23cddd29370e47e1d8393c84f5ee23 Mon Sep 17 00:00:00 2001 From: gwojda Date: Fri, 17 Feb 2017 10:32:25 +0100 Subject: [PATCH] fixe leak sur env --- 42sh/src/builtin/builtin_env.c | 3 ++- 42sh/src/history/history.c | 2 +- 42sh/src/line-editing/ft_prompt.c | 4 ++-- 42sh/src/line-editing/lib_line_editing/toolz2.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/42sh/src/builtin/builtin_env.c b/42sh/src/builtin/builtin_env.c index 67d0c2bb..f65e7357 100644 --- a/42sh/src/builtin/builtin_env.c +++ b/42sh/src/builtin/builtin_env.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:14:20 by jhalford #+# #+# */ -/* Updated: 2017/02/16 12:40:08 by gwojda ### ########.fr */ +/* Updated: 2017/02/17 10:27:05 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -131,5 +131,6 @@ int builtin_env(const char *path, char *const argv[], char *const envp[]) if (*argv) ++argv; } + ft_sstrfree(env); return (0); } diff --git a/42sh/src/history/history.c b/42sh/src/history/history.c index cab1a3ac..5464edc3 100644 --- a/42sh/src/history/history.c +++ b/42sh/src/history/history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/02 15:22:19 by gwojda #+# #+# */ -/* Updated: 2017/02/09 16:24:02 by jhalford ### ########.fr */ +/* Updated: 2017/02/16 16:12:59 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line-editing/ft_prompt.c b/42sh/src/line-editing/ft_prompt.c index 2302f512..a9a87efa 100644 --- a/42sh/src/line-editing/ft_prompt.c +++ b/42sh/src/line-editing/ft_prompt.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */ -/* Updated: 2017/02/16 12:38:58 by gwojda ### ########.fr */ +/* Updated: 2017/02/16 14:27:57 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -71,7 +71,7 @@ static int ft_currend_dir(void) env = data_singleton()->env; if (!(pwd = ft_getenv(env, "PWD"))) - return (0); + return (-1); if (ft_getenv(env, "HOME") && !ft_strcmp(pwd, ft_getenv(env, "HOME"))) { ft_printf("%c ", '~'); diff --git a/42sh/src/line-editing/lib_line_editing/toolz2.c b/42sh/src/line-editing/lib_line_editing/toolz2.c index 9db4d662..e22e9fb7 100644 --- a/42sh/src/line-editing/lib_line_editing/toolz2.c +++ b/42sh/src/line-editing/lib_line_editing/toolz2.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/07 11:00:28 by gwojda #+# #+# */ -/* Updated: 2017/02/14 14:43:32 by gwojda ### ########.fr */ +/* Updated: 2017/02/16 16:05:40 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,7 +25,7 @@ void ft_puttermcaps(char *str) char *res; char *env; - env = getenv("TERM"); + env = ft_getenv(data_singleton()->env, "TERM"); if ((res = tgetstr(str, &env)) == NULL) return ; tputs(res, 0, ft_put);