alpm_list_reverse: restore original list on failure

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2024-01-25 15:35:23 +10:00
parent 845dadf183
commit 2079f6866a

View file

@ -417,6 +417,7 @@ alpm_list_t SYMEXPORT *alpm_list_reverse(alpm_list_t *list)
while(lp) { while(lp) {
if(alpm_list_append(&newlist, lp->data) == NULL) { if(alpm_list_append(&newlist, lp->data) == NULL) {
alpm_list_free(newlist); alpm_list_free(newlist);
list->prev = backup;
return NULL; return NULL;
} }
lp = lp->prev; lp = lp->prev;