[pacman-dev] [PATCH 4/5] conflict_new: free memory on error
Allan McRae
allan at archlinux.org
Wed Dec 24 01:01:40 UTC 2014
Signed-off-by: Allan McRae <allan at archlinux.org>
---
lib/libalpm/conflict.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 6402ab3..40cbb95 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -52,11 +52,15 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
conflict->package1_hash = pkg1->name_hash;
conflict->package2_hash = pkg2->name_hash;
- STRDUP(conflict->package1, pkg1->name, return NULL);
- STRDUP(conflict->package2, pkg2->name, return NULL);
+ STRDUP(conflict->package1, pkg1->name, goto error);
+ STRDUP(conflict->package2, pkg2->name, goto error);
conflict->reason = reason;
return conflict;
+
+error:
+ alpm_conflict_free(conflict);
+ return NULL;
}
/**
--
2.2.1
More information about the pacman-dev
mailing list