FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

LinkBack Thread Tools
Old 02-29-2012, 10:42 PM
Dan McGee
Default 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>

For maint. Seen when testing the previous patch.

lib/libalpm/be_package.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 4d9d0e8..ad34640 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -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 */
if((archive = archive_read_new()) == NULL) {
- alpm_pkg_free(newpkg);
+ _alpm_pkg_free(newpkg);

@@ -391,8 +391,8 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,

if(archive_read_open_filename(archive, pkgfile,
- alpm_pkg_free(newpkg);
+ handle->pm_errno = ALPM_ERR_PKG_OPEN;
+ goto error;

_alpm_log(handle, ALPM_LOG_DEBUG, "starting package load for %s
", pkgfile);

Thread Tools

All times are GMT. The time now is 12:18 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org