summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2014-11-17 15:34:46 +0100
committerAllan McRae <allan@archlinux.org>2014-11-18 02:58:26 +0100
commit5d618438c4831af92e82251051a128e8591fef59 (patch)
tree98406e03c9991f030f4b2b7a42e0dbf6eccac1d5
parenta7298c36fdc58ae4d9007a69adea988fbb9cd0db (diff)
downloadpacman-5d618438c4831af92e82251051a128e8591fef59.tar.gz
pacman-5d618438c4831af92e82251051a128e8591fef59.tar.xz
_alpm_backup_dup: fix memory leak in error case
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--lib/libalpm/backup.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c
index c2989b6d..aeb41316 100644
--- a/lib/libalpm/backup.c
+++ b/lib/libalpm/backup.c
@@ -87,10 +87,15 @@ alpm_backup_t *_alpm_backup_dup(const alpm_backup_t *backup)
alpm_backup_t *newbackup;
CALLOC(newbackup, 1, sizeof(alpm_backup_t), return NULL);
- STRDUP(newbackup->name, backup->name, return NULL);
- STRDUP(newbackup->hash, backup->hash, return NULL);
+ STRDUP(newbackup->name, backup->name, goto error);
+ STRDUP(newbackup->hash, backup->hash, goto error);
return newbackup;
+
+error:
+ free(newbackup->name);
+ free(newbackup);
+ return NULL;
}
/* vim: set noet: */