From 6e8079aba03dd0f9d6c28f183fa5878223c61c66 Mon Sep 17 00:00:00 2001 From: Andrii Hermaniuk Date: Fri, 29 Apr 2022 11:46:14 +0200 Subject: [PATCH] lol --- du7/snake.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/du7/snake.c b/du7/snake.c index 6feb43f..473ed77 100644 --- a/du7/snake.c +++ b/du7/snake.c @@ -15,9 +15,12 @@ struct snake* add_snake(struct snake* snake,int x,int y){ } struct snake* remove_snake(struct snake* snake){ - if(!snake->next&&!snake) + if(!snake) return NULL; - + if(!snake->next){ + free(snake); + return NULL; + } struct snake* last = snake; struct snake* secondLast = snake;