Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/be_sync.c
diff options
context:
space:
mode:
authorIvy Foster <ivy.foster@gmail.com>2016-09-08 21:03:50 -0500
committerAndrew Gregory <andrew.gregory.8@gmail.com>2017-05-08 23:27:42 -0400
commit1f3793e71a601e4e6cff2d8df50683d36435e50d (patch)
treee766e0d383f0de8bcd35e8a7adb04db64dc49d85 /lib/libalpm/be_sync.c
parent9e3aeb30d360f3ed35d0291c99e88195c5709a73 (diff)
lib/libalpm/be_sync.c: Close memory leaks when mallocing while out of memory
Signed-off-by: Ivy Foster <ivy.foster@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org> (cherry picked from commit 900a22b90c8f8c76b6d5acde9c1d55d7ba65afdb)
Diffstat (limited to 'lib/libalpm/be_sync.c')
-rw-r--r--lib/libalpm/be_sync.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 32a669db..06f96199 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -231,8 +231,13 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* print server + filename into a buffer */
len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2;
- /* TODO fix leak syncpath and umask unset */
- MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+ MALLOC(payload.fileurl, len,
+ {
+ free(syncpath);
+ umask(oldmask);
+ RET_ERR(handle, ALPM_ERR_MEMORY, -1);
+ }
+ );
snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext);
payload.handle = handle;
payload.force = force;
@@ -271,8 +276,13 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
len = strlen(server) + strlen(db->treename) + strlen(dbext) + 6;
}
- /* TODO fix leak syncpath and umask unset */
- MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+ MALLOC(payload.fileurl, len,
+ {
+ free(syncpath);
+ umask(oldmask);
+ RET_ERR(handle, ALPM_ERR_MEMORY, -1);
+ }
+ );
if(final_db_url != NULL) {
snprintf(payload.fileurl, len, "%s.sig", final_db_url);