diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/llist.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/llist.c b/lib/llist.c index dbb5352a..2969102d 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -55,10 +55,12 @@ void *dlist_pop(void *list) { struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist; + if (!dlist) return 0; if (dlist->next == dlist) *pdlist = 0; else { - dlist->next->prev = dlist->prev; - dlist->prev->next = *pdlist = dlist->next; + if (dlist->next) dlist->next->prev = dlist->prev; + if (dlist->prev) dlist->prev->next = dlist->next; + *pdlist = dlist->next; } return dlist; |