mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-05-11 06:58:47 +02:00
「🔨」 fix(builtins/ft_exit): fixed leaks :D
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user