diff --git a/srcs/ft_lsterase.c b/srcs/ft_lsterase.c index 75e477d..d05522c 100644 --- a/srcs/ft_lsterase.c +++ b/srcs/ft_lsterase.c @@ -6,7 +6,7 @@ /* By: simplonco +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/03/24 15:31:16 by simplonco #+# #+# */ -/* Updated: 2022/03/24 15:40:32 by simplonco ### ########.fr */ +/* Updated: 2022/03/24 20:54:20 by simplonco ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,8 +22,10 @@ void ft_lsterase(t_list *lst, void (*del)(void *)) if (!lst || !del) return ; del(lst->content); - lst->prev->next = lst->next; - lst->next->prev = lst->prev; + if (lst->prev) + lst->prev->next = lst->next; + if (lst->next) + lst->next->prev = lst->prev; free(lst); lst = NULL; }