From 5d618438c4831af92e82251051a128e8591fef59 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 18 Nov 2014 00:34:46 +1000 Subject: _alpm_backup_dup: fix memory leak in error case Signed-off-by: Allan McRae --- lib/libalpm/backup.c | 9 +++++++-- 1 file 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: */ -- cgit v1.2.3-70-g09d2