From: Michael Tremer Date: Mon, 16 Oct 2023 15:32:40 +0000 (+0000) Subject: repo: Keep a reference to the context X-Git-Tag: 0.9.30~1486 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68f827f97f8ed23c71e9bc42811a100956541d71;p=pakfire.git repo: Keep a reference to the context Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index 7c7442626..fc488c642 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +82,7 @@ struct pakfire_repo_appdata { }; struct pakfire_repo { + struct pakfire_ctx* ctx; struct pakfire* pakfire; int nrefs; @@ -743,7 +745,10 @@ static void pakfire_repo_free(struct pakfire_repo* repo, const int free_repo) { if (repo->mirrorlist) pakfire_mirrorlist_unref(repo->mirrorlist); - pakfire_unref(repo->pakfire); + if (repo->pakfire) + pakfire_unref(repo->pakfire); + if (repo->ctx) + pakfire_ctx_unref(repo->ctx); free(repo); } @@ -792,6 +797,9 @@ PAKFIRE_EXPORT int pakfire_repo_create(struct pakfire_repo** repo, if (!rep) return 1; + // Store a reference to the context + rep->ctx = pakfire_ctx(pakfire); + rep->pakfire = pakfire_ref(pakfire); rep->nrefs = 1;