summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSören Brinkmann <soeren.brinkmann@gmail.com>2014-03-11 19:29:22 -0700
committerAllan McRae <allan@archlinux.org>2014-03-27 15:16:52 +1000
commitfb8437b588356f2efd9dd093a304edc3a1859a1d (patch)
tree62f42fda9875b068d0998e1165d3a3d4542279c8 /src
parentfcf0cefd1a9ae9bd3319c82a77ed38d7a2bc8db3 (diff)
downloadpacman-fb8437b588356f2efd9dd093a304edc3a1859a1d.tar.xz
pacman/upgrade: Fix memory leaks
Make sure allocated memory is freed before returning. Signed-off-by: Sören Brinkmann <soeren.brinkmann@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/upgrade.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index cbc605d6..a6be0e18 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -75,12 +75,13 @@ int pacman_upgrade(alpm_list_t *targets)
}
if(retval) {
- return retval;
+ goto fail_free;
}
/* Step 1: create a new transaction */
if(trans_init(config->flags, 1) == -1) {
- return 1;
+ retval = 1;
+ goto fail_free;
}
printf(_("loading packages...\n"));
@@ -112,15 +113,21 @@ int pacman_upgrade(alpm_list_t *targets)
config->explicit_adds = alpm_list_add(config->explicit_adds, pkg);
}
- free(file_is_remote);
-
if(retval) {
- trans_release();
- return retval;
+ goto fail_release;
}
+ free(file_is_remote);
+
/* now that targets are resolved, we can hand it all off to the sync code */
return sync_prepare_execute();
+
+fail_release:
+ trans_release();
+fail_free:
+ free(file_is_remote);
+
+ return retval;
}
/* vim: set noet: */