From 667beff2598d47ac96e41c4e29f090abfb65474d Mon Sep 17 00:00:00 2001 From: y-syo Date: Mon, 24 Jun 2024 10:32:19 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix(env):=20ge?= =?UTF-8?q?tters=20now=20dup=20the=20value,=20protect=20possible=20unwante?= =?UTF-8?q?d=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/env/env_cmd.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/env/env_cmd.c b/src/env/env_cmd.c index c68df38..9d25b6d 100644 --- a/src/env/env_cmd.c +++ b/src/env/env_cmd.c @@ -6,7 +6,7 @@ /* By: mmoussou name, name)) env = env->next; if (env) - return (env->content); + { + value = ft_strdup(env->content); + return (value); + } return (NULL); } char *env_getn_value(char *name, t_env *env, int n) { + char *value; + while (env && ft_strncmp(env->name, name, n)) env = env->next; if (env) - return (env->content); + { + value = ft_strdup(env->content); + return (value); + } return (NULL); }