From 3ebb7b94d92cbdbf3f03ba8f13e15df7dca26e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Brinkmann?= Date: Tue, 11 Mar 2014 19:29:20 -0700 Subject: [PATCH] pacman/upgrade: Check malloc() return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the return value of malloc() before dereferencing the returned pointer. Signed-off-by: Sören Brinkmann Signed-off-by: Allan McRae --- src/pacman/upgrade.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 5416f618..11da4dcb 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -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);