diff options
-rw-r--r-- | list.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -13,6 +13,9 @@ struct list *list_create() { /* frees all memory associated with the list */ void list_destroy(struct list *list) { struct list_node *node, *next; + + if (!list) + return; for (node = list->first; node; node = next) { free(node->data); @@ -47,7 +50,7 @@ void *list_shift(struct list *list) { struct list_node *node; void *data; - if (!list->first) + if (!list || !list->first) return NULL; node = list->first; |