aboutsummaryrefslogtreecommitdiff
path: root/libs/libc/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libc/list.c')
-rw-r--r--libs/libc/list.c7
1 files changed, 4 insertions, 3 deletions
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)