index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2007-11-11 10:47:28 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-11-11 10:47:28 -0600 |
commit | 4a835f5f53f23d3564ceb4f53b84f4b62b0074fe (patch) | |
tree | 399018b5566a4dc750c795eb5c5df149e7e721fc /lib/libalpm/alpm_list.c | |
parent | b6b3b0135edd7bf0fae43bfe522e41cfa5eb0d9b (diff) |
-rw-r--r-- | lib/libalpm/alpm_list.c | 12 |
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index d3a7951f..465c1a8f 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -301,14 +301,22 @@ alpm_list_t SYMEXPORT *alpm_list_remove(alpm_list_t *haystack, const void *needl if(i == haystack) { /* Special case: removing the head node which has a back reference to * the tail node */ - /* The item found is the first in the chain */ haystack = i->next; if(haystack) { haystack->prev = i->prev; } i->prev = NULL; + } else if(i == haystack->prev) { + /* Special case: removing the tail node, so we need to fix the back + * reference on the head node. We also know tail != head. */ + if(i->prev) { + /* i->next should always be null */ + i->prev->next = i->next; + haystack->prev = i->prev; + i->prev = NULL; + } } else { - /* Normal case, non-head node */ + /* Normal case, non-head and non-tail node */ if(i->next) { i->next->prev = i->prev; } |