summaryrefslogtreecommitdiff
path: root/lib/libalpm/conflict.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/conflict.c')
-rw-r--r--lib/libalpm/conflict.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index db07102c..0af3e3a8 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -1,7 +1,7 @@
/*
* conflict.c
*
- * Copyright (c) 2006-2014 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2015 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
@@ -48,15 +48,19 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
{
alpm_conflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_conflict_t), return NULL);
+ CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
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;
}
/**
@@ -79,11 +83,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;
}
/**
@@ -265,7 +273,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
{
alpm_fileconflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_fileconflict_t), goto error);
+ CALLOC(conflict, 1, sizeof(alpm_fileconflict_t), goto error);
STRDUP(conflict->target, pkg1->name, goto error);
STRDUP(conflict->file, filestr, goto error);
@@ -284,6 +292,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
return conflicts;
error:
+ alpm_fileconflict_free(conflict);
RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
}