remove_obsoletes: deal with unexistent arrays in both dictionaries.

This commit is contained in:
Juan RP 2012-09-30 08:57:57 +02:00
parent 0ab888a79c
commit 5228b3fbf3

View File

@ -59,12 +59,11 @@ xbps_remove_obsoletes(struct xbps_handle *xhp,
again: again:
iter = xbps_array_iter_from_dict(oldd, array_str); iter = xbps_array_iter_from_dict(oldd, array_str);
if (iter == NULL) if (iter == NULL)
return errno; goto out1;
iter2 = xbps_array_iter_from_dict(newd, array_str); iter2 = xbps_array_iter_from_dict(newd, array_str);
if (iter2 == NULL) { if (iter2 == NULL)
prop_object_iterator_release(iter); goto out1;
return errno;
}
/* /*
* Check for obsolete files, i.e files/links/dirs available in * Check for obsolete files, i.e files/links/dirs available in
* the old package list not found in new package list. * the old package list not found in new package list.
@ -164,15 +163,18 @@ again:
"%s: removed obsolete entry: %s", pkgver, file); "%s: removed obsolete entry: %s", pkgver, file);
free(file); free(file);
} }
out1:
if (!dolinks) { if (!dolinks) {
/* /*
* Now look for obsolete links. * Now look for obsolete links.
*/ */
dolinks = true; dolinks = true;
array_str = "links"; array_str = "links";
prop_object_iterator_release(iter2); if (iter2)
prop_object_iterator_release(iter); prop_object_iterator_release(iter2);
iter2 = NULL; if (iter)
prop_object_iterator_release(iter);
iter2 = iter = NULL;
goto again; goto again;
} }
if (!dodirs) { if (!dodirs) {
@ -181,15 +183,19 @@ again:
*/ */
dodirs = true; dodirs = true;
array_str = "dirs"; array_str = "dirs";
prop_object_iterator_release(iter2); if (iter2)
prop_object_iterator_release(iter); prop_object_iterator_release(iter2);
iter2 = NULL; if (iter)
prop_object_iterator_release(iter);
iter2 = iter = NULL;
goto again; goto again;
} }
out: out:
prop_object_iterator_release(iter2); if (iter2)
prop_object_iterator_release(iter); prop_object_iterator_release(iter2);
if (iter)
prop_object_iterator_release(iter);
return rv; return rv;
} }