summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2016-06-06 20:12:30 +0200
committerAllan McRae <allan@archlinux.org>2016-08-30 10:10:40 +0200
commit681509fd445ed6012e6ecf89b49e9c00d83b70cd (patch)
treeb2ffc59587c3277d79b70b8bd11abed994f22dd6 /lib/libalpm/add.c
parent1291c04961e6c27e93ef376583d46ec2aa3036a1 (diff)
downloadpacman-681509fd445ed6012e6ecf89b49e9c00d83b70cd.tar.gz
pacman-681509fd445ed6012e6ecf89b49e9c00d83b70cd.tar.xz
Release resources on error paths.
Some resources (memory or file descriptors) are not released on all error paths. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index f5c9a957..d132e522 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -466,7 +466,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
}
}
- /* prepare directory for database entries so permission are correct after
+ /* prepare directory for database entries so permissions are correct after
changelog/install script installation */
if(_alpm_local_db_prepare(db, newpkg)) {
alpm_logaction(handle, ALPM_CALLER_PREFIX,
@@ -503,6 +503,9 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
_alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
handle->root, strerror(errno));
_alpm_archive_read_free(archive);
+ if(cwdfd >= 0) {
+ close(cwdfd);
+ }
close(fd);
ret = -1;
goto cleanup;