libxbps: do not insert/delete while traversing a (double) locked iterator.
This commit is contained in:
parent
b9136c61c9
commit
731c903026
@ -39,44 +39,33 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
prop_array_t replaces, instd_reqby, unsorted;
|
prop_array_t replaces, instd_reqby, unsorted;
|
||||||
prop_dictionary_t instd, reppkgd, filesd;
|
prop_dictionary_t instd, reppkgd, filesd;
|
||||||
prop_object_t obj, obj2;
|
prop_object_t obj, obj2;
|
||||||
prop_object_iterator_t iter, iter2;
|
prop_object_iterator_t iter;
|
||||||
const char *pattern, *pkgname, *curpkgname, *pkgver, *curpkgver;
|
const char *pattern, *pkgname, *curpkgname, *pkgver, *curpkgver;
|
||||||
char *buf;
|
char *buf;
|
||||||
bool instd_auto, sr;
|
bool instd_auto, sr;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||||
|
|
||||||
iter = prop_array_iterator(unsorted);
|
for (i = 0; i < prop_array_count(unsorted); i++) {
|
||||||
assert(iter);
|
obj = prop_array_get(unsorted, i);
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
|
||||||
replaces = prop_dictionary_get(obj, "replaces");
|
replaces = prop_dictionary_get(obj, "replaces");
|
||||||
if (replaces == NULL || prop_array_count(replaces) == 0)
|
if (replaces == NULL || prop_array_count(replaces) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
iter2 = prop_array_iterator(replaces);
|
iter = prop_array_iterator(replaces);
|
||||||
if (iter2 == NULL) {
|
assert(iter);
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
return ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((obj2 = prop_object_iterator_next(iter2)) != NULL) {
|
while ((obj2 = prop_object_iterator_next(iter)) != NULL) {
|
||||||
pattern = prop_string_cstring_nocopy(obj2);
|
pattern = prop_string_cstring_nocopy(obj2);
|
||||||
assert(pattern != NULL);
|
|
||||||
/*
|
/*
|
||||||
* Find the installed package that matches the pattern
|
* Find the installed package that matches the pattern
|
||||||
* to be replaced.
|
* to be replaced.
|
||||||
*/
|
*/
|
||||||
instd = xbps_pkgdb_get_pkg(xhp, pattern);
|
if (((instd = xbps_pkgdb_get_pkg(xhp, pattern)) == NULL) &&
|
||||||
if (instd == NULL) {
|
((instd = xbps_pkgdb_get_virtualpkg(xhp, pattern)) == NULL))
|
||||||
/*
|
|
||||||
* No package installed has been matched,
|
|
||||||
* try looking for a virtual package.
|
|
||||||
*/
|
|
||||||
instd = xbps_pkgdb_get_virtualpkg(xhp, pattern);
|
|
||||||
if (instd == NULL)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
prop_dictionary_get_cstring_nocopy(obj,
|
prop_dictionary_get_cstring_nocopy(obj,
|
||||||
"pkgname", &pkgname);
|
"pkgname", &pkgname);
|
||||||
prop_dictionary_get_cstring_nocopy(obj,
|
prop_dictionary_get_cstring_nocopy(obj,
|
||||||
@ -171,7 +160,6 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
free(buf);
|
free(buf);
|
||||||
prop_object_release(filesd);
|
prop_object_release(filesd);
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
prop_object_iterator_release(iter2);
|
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
prop_object_release(filesd);
|
prop_object_release(filesd);
|
||||||
@ -185,9 +173,8 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
"transaction", "remove");
|
"transaction", "remove");
|
||||||
prop_array_add(unsorted, instd);
|
prop_array_add(unsorted, instd);
|
||||||
}
|
}
|
||||||
prop_object_iterator_release(iter2);
|
|
||||||
}
|
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user