🔨」 fix(builtins/ft_exit): fixed leaks :D

This commit is contained in:
yosyo
2024-07-15 15:52:56 +02:00
parent 9a5ff21103
commit de3b52d9d4
4 changed files with 22 additions and 9 deletions

View File

@ -6,11 +6,12 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/14 13:46:57 by adjoly #+# #+# */
/* Updated: 2024/07/15 15:14:57 by mmoussou ### ########.fr */
/* Updated: 2024/07/15 15:49:06 by mmoussou ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include "builtins.h"
int check_exit_value(char *str)
{
@ -30,7 +31,7 @@ int check_exit_value(char *str)
return (0);
}
void ft_exit(char **argv, int ac)
void ft_exit(char **argv, int ac, char **env_array, t_env *env)
{
int return_value;
@ -39,6 +40,7 @@ void ft_exit(char **argv, int ac)
if (check_exit_value(argv[1]))
{
printf("minishell: exit: %s: numeric argument required\n", argv[1]);
free_exit(env, env_array);
exit(2);
}
else
@ -50,6 +52,7 @@ void ft_exit(char **argv, int ac)
return_value = atoi(argv[1]);
if (return_value == -1)
return_value += 255;
free_exit(env, env_array);
exit(get_exit_code(return_value));
}
}