1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

pacman/upgrade: Check malloc() return value

Check the return value of malloc() before dereferencing the returned pointer.

Signed-off-by: Sören Brinkmann <soeren.brinkmann@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Sören Brinkmann 2014-03-11 19:29:20 -07:00 committed by Allan McRae
parent 912ea363de
commit 3ebb7b94d9

View File

@ -51,6 +51,10 @@ int pacman_upgrade(alpm_list_t *targets)
*/
for(i = targets; i; i = alpm_list_next(i)) {
int *r = malloc(sizeof(int));
if(r == NULL) {
pm_printf(ALPM_LOG_ERROR, _("memory exhausted\n"));
return 1;
}
if(strstr(i->data, "://")) {
char *str = alpm_fetch_pkgurl(config->handle, i->data);