From 2c69345acc141856e2b395e1c269c91716e9ad7e Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 9 Jan 2019 17:58:44 +0000 Subject: [PATCH] Don't process processed packages again in collect_rdeps Otherwise we will get exponential time complexity --- lib/package_fulldeptree.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/package_fulldeptree.c b/lib/package_fulldeptree.c index 36e7eeb6..57c1f514 100644 --- a/lib/package_fulldeptree.c +++ b/lib/package_fulldeptree.c @@ -107,12 +107,12 @@ collect_rdeps(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool rpool) pd->pkg = curpkgver; pd->rdeps = xbps_array_copy(currdeps); SLIST_INSERT_HEAD(&pkgdep_list, pd, pkgdep_entries); - } - if (xbps_array_count(currdeps)) { - int rv; + if (xbps_array_count(currdeps)) { + int rv; - if ((rv = collect_rdeps(xhp, curpkgd, rpool)) != 0) - return rv; + if ((rv = collect_rdeps(xhp, curpkgd, rpool)) != 0) + return rv; + } } } return 0;