1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-14 21:35:02 -05:00

Fix a memory leak when loading an invalid package

This is easily triggered via a `pacman -Sc` operation when it attempts
to open a delta file as a package- we end up leaking loads of memory
due to us never freeing the archive object. When you have upwards of
1200 delta files in your sync database directory, this results in a
memory leak of nearly 1.5 MiB.

Also fix another memory leak noticed at the same time- we need to call
the internal _alpm_pkg_free() function, as without the origin data being
set the public free function will do nothing.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2012-02-29 16:33:21 -06:00
parent d1151b5ab9
commit 4b384b7f0b

View File

@ -382,7 +382,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
/* try to create an archive object to read in the package */ /* try to create an archive object to read in the package */
if((archive = archive_read_new()) == NULL) { if((archive = archive_read_new()) == NULL) {
alpm_pkg_free(newpkg); _alpm_pkg_free(newpkg);
RET_ERR(handle, ALPM_ERR_LIBARCHIVE, NULL); RET_ERR(handle, ALPM_ERR_LIBARCHIVE, NULL);
} }
@ -391,8 +391,8 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
if(archive_read_open_filename(archive, pkgfile, if(archive_read_open_filename(archive, pkgfile,
ALPM_BUFFER_SIZE) != ARCHIVE_OK) { ALPM_BUFFER_SIZE) != ARCHIVE_OK) {
alpm_pkg_free(newpkg); handle->pm_errno = ALPM_ERR_PKG_OPEN;
RET_ERR(handle, ALPM_ERR_PKG_OPEN, NULL); goto error;
} }
_alpm_log(handle, ALPM_LOG_DEBUG, "starting package load for %s\n", pkgfile); _alpm_log(handle, ALPM_LOG_DEBUG, "starting package load for %s\n", pkgfile);