From 27506aba8fe1e67bff7df47922d0e5fbba17b19f Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 22 Dec 2014 17:39:47 +1000 Subject: _alpm_conflict_dup: fix memory leak on error Signed-off-by: Allan McRae --- lib/libalpm/conflict.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index db07102c..63b83048 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -79,11 +79,15 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict) newconflict->package1_hash = conflict->package1_hash; newconflict->package2_hash = conflict->package2_hash; - STRDUP(newconflict->package1, conflict->package1, return NULL); - STRDUP(newconflict->package2, conflict->package2, return NULL); + STRDUP(newconflict->package1, conflict->package1, goto error); + STRDUP(newconflict->package2, conflict->package2, goto error); newconflict->reason = conflict->reason; return newconflict; + +error: + alpm_conflict_free(newconflict); + return NULL; } /** -- cgit v1.2.3-70-g09d2