[pacman-dev] [PATCH] conflict error return fix in sync.c
Nagy Gabor
ngaba at bibl.u-szeged.hu
Thu Jan 24 17:00:39 EST 2008
From 1225b562d9ce5eb96cc3a391d7a6eb5553ff7450 Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba at bibl.u-szeged.hu>
Date: Thu, 24 Jan 2008 22:52:58 +0100
Subject: [PATCH] conflict error return fix in sync.c
*some memleak fixes
*unify return lists (inner vs outer conflict)
Note: this patch introduces some code duplication, which should be fixed, when fixing FS#7524
Signed-off-by: Nagy Gabor <ngaba at bibl.u-szeged.hu>
---
lib/libalpm/sync.c | 29 +++++++++++++----------------
1 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 3e99795..603214d 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -485,9 +485,15 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
rsync = sync1;
sync = sync2;
} else {
+ _alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
pm_errno = PM_ERR_CONFLICTING_DEPS;
ret = -1;
- *data = deps;
+ if(data) {
+ *data = deps;
+ } else {
+ alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
+ alpm_list_free(deps);
+ }
goto cleanup;
}
@@ -552,23 +558,14 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
sync->data = alpm_list_add(sync->data, local);
} else { /* abort */
_alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
- if(data) {
- pmconflict_t *retconflict;
- MALLOC(retconflict, sizeof(pmconflict_t), 0);
- if(!retconflict) {
- pm_errno = PM_ERR_MEMORY;
- alpm_list_free_inner(*data, (alpm_list_fn_free)_alpm_conflict_free);
- alpm_list_free(*data);
- ret = -1;
- goto cleanup;
- }
- *retconflict = *conflict;
- *data = alpm_list_add(*data, retconflict);
- }
pm_errno = PM_ERR_CONFLICTING_DEPS;
ret = -1;
- alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
- alpm_list_free(deps);
+ if(data) {
+ *data = deps;
+ } else {
+ alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
+ alpm_list_free(deps);
+ }
goto cleanup;
}
}
--
1.5.3.7
More information about the pacman-dev
mailing list