From 3436bc6c3e24dccde97021c6460acff6dd7f5a56 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 12 Dec 2022 23:44:10 +1000 Subject: [PATCH] Finish comparing all pairs of filenames for duplicates before erroring This also prevents a use-after-free issue where we free the list we are interating over and the do i->next. Signed-off-by: Allan McRae --- lib/libalpm/sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 49bde401..3be2ddcc 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -470,7 +470,6 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data) for(j = i->next; j; j = j->next) { alpm_pkg_t *pkg2 = j->data; if(strcmp(pkg1->filename, pkg2->filename) == 0) { - alpm_list_free(resolved); ret = -1; handle->pm_errno = ALPM_ERR_TRANS_DUP_FILENAME; _alpm_log(handle, ALPM_LOG_ERROR, _("packages %s and %s have the same filename: %s\n"), @@ -480,6 +479,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data) } if(ret != 0) { + alpm_list_free(resolved); goto cleanup; }