TP 9 exo2: Better handling of special cases in list_delete()
[TD_C.git] / TP_9 / exo2 / clist.c
index edc296473e54c3910d0d4ea5fe3c3058aaf2913a..9ebb34817e5982fa3b3131e388d01b320f6a3a70 100644 (file)
@@ -57,7 +57,9 @@ link_t* list_delete(link_t* head, unsigned index) {
     link_t* head_next = NULL;
     link_t* head_ret = NULL;
    
-    if (index == 0) {
+    if (head == NULL) {
+        return NULL;
+    } else if (index == 0) {
         head_next = head->next;
         free(head);
         head = head_next;