[pacman-dev] [PATCH 1/5] create_tempfile: fix memory leak on error
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/dload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index e3409f9..c5186be 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -379,7 +379,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat payload->tempfile_name = randpath; free(payload->remote_name); STRDUP(payload->remote_name, strrchr(randpath, '/') + 1, - RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL)); + fclose(fp); RET_ERR(payload->handle, ALPM_ERR_MEMORY, NULL)); return fp; } -- 2.2.1
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/conflict.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 63b8304..6402ab3 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -288,6 +288,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle, return conflicts; error: + alpm_fileconflict_free(conflict); RET_ERR(handle, ALPM_ERR_MEMORY, conflicts); } -- 2.2.1
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/trans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 7cdb096..e680feb 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -343,7 +343,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath, /* either extract or copy the scriptlet */ len += strlen("/.INSTALL"); - MALLOC(scriptfn, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + MALLOC(scriptfn, len, free(tmpdir); RET_ERR(handle, ALPM_ERR_MEMORY, -1)); snprintf(scriptfn, len, "%s/.INSTALL", tmpdir); if(is_archive) { if(_alpm_unpack_single(handle, filepath, tmpdir, ".INSTALL")) { -- 2.2.1
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/conflict.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 6402ab3..40cbb95 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -52,11 +52,15 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, conflict->package1_hash = pkg1->name_hash; conflict->package2_hash = pkg2->name_hash; - STRDUP(conflict->package1, pkg1->name, return NULL); - STRDUP(conflict->package2, pkg2->name, return NULL); + STRDUP(conflict->package1, pkg1->name, goto error); + STRDUP(conflict->package2, pkg2->name, goto error); conflict->reason = reason; return conflict; + +error: + alpm_conflict_free(conflict); + return NULL; } /** -- 2.2.1
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/diskspace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index af87f75..c94cab3 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -112,7 +112,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle) while((mnt = getmntent(fp))) { CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); - STRDUP(mp->mount_dir, mnt->mnt_dir, RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); + STRDUP(mp->mount_dir, mnt->mnt_dir, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); mp->mount_dir_len = strlen(mp->mount_dir); mount_points = alpm_list_add(mount_points, mp); @@ -135,7 +135,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle) while((ret = getmntent(fp, &mnt)) == 0) { CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); - STRDUP(mp->mount_dir, mnt->mnt_mountp, RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); + STRDUP(mp->mount_dir, mnt->mnt_mountp, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); mp->mount_dir_len = strlen(mp->mount_dir); mount_points = alpm_list_add(mount_points, mp); @@ -162,7 +162,7 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle) for(; entries-- > 0; fsp++) { CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); - STRDUP(mp->mount_dir, fsp->f_mntonname, RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); + STRDUP(mp->mount_dir, fsp->f_mntonname, free(mp); RET_ERR(handle, ALPM_ERR_MEMORY, NULL)); mp->mount_dir_len = strlen(mp->mount_dir); memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE)); #if defined(HAVE_GETMNTINFO_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FLAG) -- 2.2.1
participants (1)
-
Allan McRae