1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-21 23:38:49 -05:00

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>
This commit is contained in:
Ivy Foster 2016-09-08 21:03:50 -05:00 committed by Allan McRae
parent 38e229e4db
commit 900a22b90c

View File

@ -231,8 +231,13 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* print server + filename into a buffer */ /* print server + filename into a buffer */
len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2; len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2;
/* TODO fix leak syncpath and umask unset */ MALLOC(payload.fileurl, len,
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); {
free(syncpath);
umask(oldmask);
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
);
snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext); snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext);
payload.handle = handle; payload.handle = handle;
payload.force = force; 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; len = strlen(server) + strlen(db->treename) + strlen(dbext) + 6;
} }
/* TODO fix leak syncpath and umask unset */ MALLOC(payload.fileurl, len,
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); {
free(syncpath);
umask(oldmask);
RET_ERR(handle, ALPM_ERR_MEMORY, -1);
}
);
if(final_db_url != NULL) { if(final_db_url != NULL) {
snprintf(payload.fileurl, len, "%s.sig", final_db_url); snprintf(payload.fileurl, len, "%s.sig", final_db_url);