summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-28 12:58:43 -0500
committerDan McGee <dan@archlinux.org>2011-09-28 13:01:03 -0500
commite0acf2f144404e613a75d5aafea2a909989544e9 (patch)
treefce12af0ebf8344e6b1c10533ee7de5707083f3c /lib/libalpm/sync.c
parent9a58d5c6c5a69ebf7a920c357820a59c19d5b641 (diff)
downloadpacman-e0acf2f144404e613a75d5aafea2a909989544e9.tar.xz
Refactor download payload reset and free
This was done to squash a memory leak in the sync database download code. When we downloaded a database and then reused the payload struct, we could find ourselves calling get_fullpath() for the signatures and overwriting non-freed values we had left over from the database download. Refactor the payload_free function into a payload_reset function that we can call that does NOT free the payload itself, so we can reuse payload structs. This also allows us to move the payload to the stack in some call paths, relieving us of the need to alloc space. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 8c50ec88..08d634d6 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -891,9 +891,8 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
}
}
- alpm_list_free_inner(files, (alpm_list_fn_free)_alpm_dload_payload_free);
- alpm_list_free(files);
- files = NULL;
+ alpm_list_free_inner(files, (alpm_list_fn_free)_alpm_dload_payload_reset);
+ FREELIST(files);
}
}