Thu, 10 Apr 2014 11:18:12 +0200
fixed ucx_list_remove crashing when removing the last element of a list
ucx/list.c | file | annotate | diff | comparison | revisions |
1.1 --- a/ucx/list.c Tue Mar 18 09:53:50 2014 +0100 1.2 +++ b/ucx/list.c Thu Apr 10 11:18:12 2014 +0200 1.3 @@ -304,18 +304,18 @@ 1.4 } 1.5 1.6 UcxList *ucx_list_remove_a(UcxAllocator *alloc, UcxList *l, UcxList *e) { 1.7 - if (e->prev == NULL) { 1.8 - if(e->next != NULL) { 1.9 - e->next->prev = NULL; 1.10 - l = e->next; 1.11 - } else { 1.12 - l = NULL; 1.13 - } 1.14 - 1.15 - } else { 1.16 - e->prev->next = e->next; 1.17 + if (l == e) { 1.18 + l = e->next; 1.19 + } 1.20 + 1.21 + if (e->next) { 1.22 e->next->prev = e->prev; 1.23 } 1.24 + 1.25 + if (e->prev) { 1.26 + e->prev->next = e->next; 1.27 + } 1.28 + 1.29 alloc->free(alloc->pool, e); 1.30 return l; 1.31 }