Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
fetch: fix crash when cleaing up the mirror list
Baptiste Daroussin committed 1 month ago
commit 655fcd8dd29a6aaeea72f1054226212f23924b3f
parent 22a108d
1 file changed +13 -6
modified libpkg/fetch_libfetch.c
@@ -283,12 +283,19 @@ libfetch_fetch(struct pkg_repo *repo, int dest, struct fetch_item *fi)
void
libfetch_cleanup(struct pkg_repo *repo)
{
-
	struct http_mirror *m, *tmp;
-

-
	LL_FOREACH_SAFE(repo->http, m, tmp) {
-
		fetchFreeURL(m->url);
-
		free(m);
+
	if (repo->mirror_type == HTTP) {
+
		struct http_mirror *m, *tmp;
+
		LL_FOREACH_SAFE(repo->http, m, tmp) {
+
			fetchFreeURL(m->url);
+
			free(m);
+
		}
+
		repo->http = NULL;
+
	} else if (repo->mirror_type == SRV) {
+
		struct dns_srvinfo *s, *stmp;
+
		LL_FOREACH_SAFE(repo->srv, s, stmp) {
+
			free(s);
+
		}
+
		repo->srv = NULL;
	}
-
	repo->http = NULL;
	fh_close(repo);
}