diff options
author | Sören Brinkmann <soeren.brinkmann@gmail.com> | 2014-03-11 19:29:20 -0700 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-03-16 13:43:33 +1000 |
commit | 3ebb7b94d92cbdbf3f03ba8f13e15df7dca26e20 (patch) | |
tree | 086b90de46247c3b50e2abd6f25bb2dee4132d40 /src/pacman | |
parent | 912ea363dec9038e9226a619364e16709720cac3 (diff) |
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>
Diffstat (limited to 'src/pacman')
-rw-r--r-- | src/pacman/upgrade.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |