[🔨] fix: Free when overflow detected

This commit is contained in:
KeyZox committed 2024-03-18 17:05:28 +01:00
1 parent 77f108d571
commit a659b8fadb
26 files changed
+20 -16

No files matched your search

BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
BIN
View File
Binary file not shown.
+7 -10
View File
@@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/04 12:14:22 by adjoly #+# #+# */
/* Updated: 2024/03/16 21:01:23 by adjoly ### ########.fr */
/* Updated: 2024/03/18 16:51:24 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@@ -26,7 +26,7 @@ void check_invalid_char(char **av)
{
if (!ft_isdigit(*tmp_args) && *tmp_args != '-' \
&& *tmp_args != '+' && *tmp_args != 32)
ft_senderror();
ft_senderror(NULL);
tmp_args++;
}
tmp++;
@@ -45,10 +45,7 @@ void check_double(t_stack **stack)
while (check_dup)
{
if (check_dup->nb == tmp->nb)
{
ft_stackclear(stack);
ft_senderror();
}
ft_senderror(stack);
check_dup = check_dup->next;
}
tmp = tmp->next;
@@ -69,9 +66,9 @@ void check_sign(char **av)
{
if ((*tmp_av == '-' || *tmp_av == '+') \
&& !ft_isdigit(*(tmp_av + 1)))
ft_senderror();
ft_senderror(NULL);
if ((*tmp_av == '-' || *tmp_av == '+') && ft_isdigit(*(tmp_av - 1)))
ft_senderror();
ft_senderror(NULL);
tmp_av++;
}
tmp++;
@@ -89,7 +86,7 @@ void check_empty_args(char **av)
{
tmp_av = *tmp;
if (!*tmp_av)
ft_senderror();
ft_senderror(NULL);
while (*tmp_av)
{
if (*tmp_av != 32)
@@ -97,7 +94,7 @@ void check_empty_args(char **av)
tmp_av++;
}
if (!*tmp_av)
ft_senderror();
ft_senderror(NULL);
tmp++;
}
}
+8 -2
View File
@@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/04 12:05:43 by adjoly #+# #+# */
/* Updated: 2024/03/16 15:13:43 by adjoly ### ########.fr */
/* Updated: 2024/03/18 16:57:06 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@@ -39,6 +39,12 @@ void ft_freearr(char **arr)
free(arr);
}
void ft_senderror_split(t_stack **stack, char **split)
{
ft_freearr(split);
ft_senderror(stack);
}
t_stack *ft_parsing(char **av)
{
t_stack *parsed_data;
@@ -57,7 +63,7 @@ t_stack *ft_parsing(char **av)
{
if (ft_nbrlen(*tmp_split) > 11 || ft_atoll(*tmp_split) > 2147483647 \
|| ft_atoll(*tmp_split) < -2147483648)
ft_senderror();
ft_senderror_split(&parsed_data, split);
ft_stackadd_back(&parsed_data, ft_stacknew(ft_atoi(*tmp_split)));
tmp_split++;
}
+2 -2
View File
@@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/04 12:18:29 by adjoly #+# #+# */
/* Updated: 2024/03/13 14:35:19 by adjoly ### ########.fr */
/* Updated: 2024/03/18 16:47:27 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@@ -68,6 +68,6 @@ void ft_print_stack(t_stack *stack);
// utils
t_boolean ft_is_sort(t_stack **stack);
void ft_senderror(void);
void ft_senderror(t_stack **stack);
#endif
+3 -2
View File
@@ -6,14 +6,15 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/11 15:47:05 by adjoly #+# #+# */
/* Updated: 2024/03/16 19:01:15 by adjoly ### ########.fr */
/* Updated: 2024/03/18 16:50:28 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "../push_swap.h"
void ft_senderror(void)
void ft_senderror(t_stack **stack)
{
ft_putendl_fd("Error", STDERR_FILENO);
ft_stackclear(stack);
exit(EXIT_FAILURE);
}