aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-06-20 16:59:49 -0500
committerRob Landley <rob@landley.net>2019-06-20 16:59:49 -0500
commit90cc056dcd7ef04405c7e4d5535eb4ad2a349155 (patch)
tree74ee8c02542d6b46f24c01f4e41178f2a3bb2e1b /lib
parentd0ff0d42782817f6a1115dd2d1b58e9c6b519d51 (diff)
downloadtoybox-90cc056dcd7ef04405c7e4d5535eb4ad2a349155.tar.gz
Teach dlist_pop() to work on a dlist_terminate()d list
Diffstat (limited to 'lib')
-rw-r--r--lib/llist.c6
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;