Closed jdagz28 closed 11 months ago
leaks in SHLVL
int shell_init_level(t_shell* shell)
{
char* line;
char* res;
char* level;
int value;
int len;
line = env_get("SHLVL=", 0, shell->env);
if (!line)
return(EXIT_FAILURE);
value = ft_atoi(line);
level = ft_itoa(value + 1);
free(line);
len = ft_strlen("SHLVL=") + ft_strlen(level) + 1;
res = malloc(sizeof(char) * len);
if (!res)
return(EXIT_FAILURE);
ft_strlcpy(res, "SHLVL=", len);
ft_strlcat(res, level, len);
export(shell, res);
**free(level);
free(res);**
return(EXIT_SUCCESS);
}
--fixed
fixed leaks in env_gepath; used ft_splitfree() instead of free()
char *env_getpath(char *str, char **env)
{
int i;
char *res;
char **paths;
paths = env_get_bin_paths(env);
if (!paths)
return (NULL);
i = 0;
while (paths[i])
{
res = env_trypath(paths[i], str);
if (res)
break ;
i++;
}
**ft_splitfree(paths);**
return (res);
}
fixed leaks in freeing tokens. free by consuming tokens while building the ast.
Signal Uninitialised.
-fixed: added
sigemptyset()
in signal_set