From 5228b3fbf3d1209b61257d5287f283168cc04582 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 30 Sep 2012 08:57:57 +0200 Subject: [PATCH] remove_obsoletes: deal with unexistent arrays in both dictionaries. --- lib/package_remove_obsoletes.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/package_remove_obsoletes.c b/lib/package_remove_obsoletes.c index a0d6c729..14736bf5 100644 --- a/lib/package_remove_obsoletes.c +++ b/lib/package_remove_obsoletes.c @@ -59,12 +59,11 @@ xbps_remove_obsoletes(struct xbps_handle *xhp, again: iter = xbps_array_iter_from_dict(oldd, array_str); if (iter == NULL) - return errno; + goto out1; iter2 = xbps_array_iter_from_dict(newd, array_str); - if (iter2 == NULL) { - prop_object_iterator_release(iter); - return errno; - } + if (iter2 == NULL) + goto out1; + /* * Check for obsolete files, i.e files/links/dirs available in * the old package list not found in new package list. @@ -164,15 +163,18 @@ again: "%s: removed obsolete entry: %s", pkgver, file); free(file); } +out1: if (!dolinks) { /* * Now look for obsolete links. */ dolinks = true; array_str = "links"; - prop_object_iterator_release(iter2); - prop_object_iterator_release(iter); - iter2 = NULL; + if (iter2) + prop_object_iterator_release(iter2); + if (iter) + prop_object_iterator_release(iter); + iter2 = iter = NULL; goto again; } if (!dodirs) { @@ -181,15 +183,19 @@ again: */ dodirs = true; array_str = "dirs"; - prop_object_iterator_release(iter2); - prop_object_iterator_release(iter); - iter2 = NULL; + if (iter2) + prop_object_iterator_release(iter2); + if (iter) + prop_object_iterator_release(iter); + iter2 = iter = NULL; goto again; } out: - prop_object_iterator_release(iter2); - prop_object_iterator_release(iter); + if (iter2) + prop_object_iterator_release(iter2); + if (iter) + prop_object_iterator_release(iter); return rv; }