# HG changeset patch # User Mike Becker # Date 1397121492 -7200 # Node ID 1031dd910f8e514c1bd61dc93d5195cdc394485d # Parent 302dddaf741daf4dfc8700df53f6aa44fa0ba592 fixed ucx_list_remove crashing when removing the last element of a list diff -r 302dddaf741d -r 1031dd910f8e ucx/list.c --- a/ucx/list.c Tue Mar 18 09:53:50 2014 +0100 +++ b/ucx/list.c Thu Apr 10 11:18:12 2014 +0200 @@ -304,18 +304,18 @@ } UcxList *ucx_list_remove_a(UcxAllocator *alloc, UcxList *l, UcxList *e) { - if (e->prev == NULL) { - if(e->next != NULL) { - e->next->prev = NULL; - l = e->next; - } else { - l = NULL; - } - - } else { - e->prev->next = e->next; + if (l == e) { + l = e->next; + } + + if (e->next) { e->next->prev = e->prev; } + + if (e->prev) { + e->prev->next = e->next; + } + alloc->free(alloc->pool, e); return l; }