summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2012-02-01 03:11:47 +1000
committerDan McGee <dan@archlinux.org>2012-01-31 11:22:30 -0600
commitfcbae69fe81d080478bbd9809af5696bbbfe9d95 (patch)
tree1fc1afc5d45baf6d41f06a34b1f3f2dcf46c8f15
parent9d1e8084dfa0a1ebae6c37e3b839289cb905116f (diff)
downloadpacman-fcbae69fe81d080478bbd9809af5696bbbfe9d95.tar.xz
Fix rare segfault on package removal
Very rarely a segfault would occur when removing a number of packages due to a corrupted list for the local database (FS#27805, FS#28195). This was caused by the alpm_list_msort function not correctly dealing with the two new head node's prev values. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/alpm_list.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index 15286aa1..3aa4f9bc 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -279,8 +279,11 @@ alpm_list_t SYMEXPORT *alpm_list_msort(alpm_list_t *list, size_t n, alpm_list_fn
alpm_list_t *left = list;
alpm_list_t *lastleft = alpm_list_nth(list, n/2 - 1);
alpm_list_t *right = lastleft->next;
- /* terminate first list */
+
+ /* tidy new lists */
lastleft->next = NULL;
+ right->prev = left->prev;
+ left->prev = lastleft;
left = alpm_list_msort(left, n/2, fn);
right = alpm_list_msort(right, n - (n/2), fn);