]> granicus.if.org Git - curl/commitdiff
Curl_llist_remove: fix potential NULL pointer deref
authorDaniel Stenberg <daniel@haxx.se>
Mon, 20 Nov 2017 21:59:19 +0000 (22:59 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 21 Nov 2017 08:02:40 +0000 (09:02 +0100)
Fixes a scan-build warning.

lib/llist.c

index 4bb0a51b865c6d29de8039275096fc3e30e788d2..f8769c2af84200cc7ee54e73808a643799188cfe 100644 (file)
@@ -106,7 +106,11 @@ Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e,
       e->next->prev = NULL;
   }
   else {
-    e->prev->next = e->next;
+    if(!e->prev)
+      list->head = e->next;
+    else
+      e->prev->next = e->next;
+
     if(!e->next)
       list->tail = e->prev;
     else