From 707fa6cb057b53846aaa27a505fe05226612ecd3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 17 Jun 2015 09:09:17 +0200 Subject: [PATCH] src/utils_llist.c: Handle unlikely corner case. This handles the following (unlikely) case: (l->head == NULL) && (e == NULL) In this case, the following code will dereference a NULL pointer: if (l->head == e) l->head = e->next; --- src/utils_llist.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils_llist.c b/src/utils_llist.c index 6a0c6f06..11f838d2 100644 --- a/src/utils_llist.c +++ b/src/utils_llist.c @@ -120,6 +120,9 @@ void llist_remove (llist_t *l, llentry_t *e) { llentry_t *prev; + if ((l == NULL) || (e == NULL)) + return; + prev = l->head; while ((prev != NULL) && (prev->next != e)) prev = prev->next; -- 2.11.0