Archived
1
0

[🔨] fix: Free when overflow detected

This commit is contained in:
2024-03-18 17:05:28 +01:00
parent 77f108d571
commit a659b8fadb
26 changed files with 20 additions and 16 deletions

BIN
obj/algo/algo.o Normal file

Binary file not shown.

BIN
obj/algo/get_min_max.o Normal file

Binary file not shown.

BIN
obj/algo/insertion.o Normal file

Binary file not shown.

BIN
obj/algo/median.o Normal file

Binary file not shown.

BIN
obj/algo/small_mouv.o Normal file

Binary file not shown.

BIN
obj/main.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
obj/parsing.o Normal file

Binary file not shown.

BIN
obj/print_stack.o Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
obj/stack/ft_stackclear.o Normal file

Binary file not shown.

BIN
obj/stack/ft_stackdelone.o Normal file

Binary file not shown.

BIN
obj/stack/ft_stacklast.o Normal file

Binary file not shown.

BIN
obj/stack/ft_stacknew.o Normal file

Binary file not shown.

BIN
obj/stack/ft_stacksize.o Normal file

Binary file not shown.

BIN
obj/utils/is_sorted.o Normal file

Binary file not shown.

BIN
obj/utils/print_error.o Normal file

Binary file not shown.

BIN
push_swap Executable file

Binary file not shown.

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++;
}
}

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++;
}

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

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);
}