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;