diff options
Diffstat (limited to 'lib/llist.c')
-rw-r--r-- | lib/llist.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/llist.c b/lib/llist.c index 596da40f..71a187db 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -37,8 +37,11 @@ void *dlist_pop(void *list) { struct double_list **pdlist = (struct double_list **)list, *dlist = *pdlist; - dlist->next->prev = dlist->prev; - dlist->prev->next = *pdlist = dlist->next; + if (dlist->next == dlist) *pdlist = 0; + else { + dlist->next->prev = dlist->prev; + dlist->prev->next = *pdlist = dlist->next; + } return dlist; } |