From df5a8c5b32733ae5e2d872b1c7baa4311a9d2308 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 15 May 2021 22:36:21 +0200 Subject: Strange fixes I have no ideas halp --- libs/libc/list.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libs/libc/list.c') diff --git a/libs/libc/list.c b/libs/libc/list.c index 53bfa08..bda9e20 100644 --- a/libs/libc/list.c +++ b/libs/libc/list.c @@ -22,11 +22,12 @@ void list_destroy(struct list *list) break; } iterator = iterator->next; - free(iterator->prev); + + if (iterator && iterator->prev) + free(iterator->prev); } - list->head = NULL; + memset(list, 0, sizeof(*list)); free(list); - list = NULL; } static struct node *list_new_node(void) -- cgit v1.2.3