shlvl_init() fixed leak
This commit is contained in:
14
srcs/init.c
14
srcs/init.c
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/08 09:22:12 by lperrey #+# #+# */
|
/* Created: 2021/10/08 09:22:12 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/12/08 06:27:51 by lperrey ### ########.fr */
|
/* Updated: 2021/12/08 21:54:36 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -42,6 +42,7 @@ int init(t_all *c)
|
|||||||
static int shlvl_init(void)
|
static int shlvl_init(void)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
int ret;
|
||||||
|
|
||||||
tmp = getenv("SHLVL");
|
tmp = getenv("SHLVL");
|
||||||
if (tmp && ft_isdigit_str(tmp))
|
if (tmp && ft_isdigit_str(tmp))
|
||||||
@@ -52,14 +53,13 @@ static int shlvl_init(void)
|
|||||||
tmp = ft_strjoinfree_s2("SHLVL=", tmp);
|
tmp = ft_strjoinfree_s2("SHLVL=", tmp);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
return (0);
|
return (0);
|
||||||
if (export_var(tmp) == -1)
|
ret = export_var(tmp);
|
||||||
return (0);
|
free(tmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
ret = export_var("SHLVL=1");
|
||||||
if (export_var("SHLVL=1") == -1)
|
if (ret == -1)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user