From d12def13f697c662a12c50b54a8d76d830d82f82 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 30 Apr 2024 11:04:31 +1000 Subject: [PATCH] catzs->view should maintain a view reference Use dns_view_weakattach and dns_view_weakdetach to maintain a reference to the view referenced through catzs->view. (cherry picked from commit 307e3ed9a66a2a90f38c59f7854529ffb76d93f8) --- lib/dns/catz.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/dns/catz.c b/lib/dns/catz.c index a8727014ca..616d598e30 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -818,7 +818,12 @@ dns_catz_catzs_set_view(dns_catz_zones_t *catzs, dns_view_t *view) { /* Either it's a new one or it's being reconfigured. */ REQUIRE(catzs->view == NULL || !strcmp(catzs->view->name, view->name)); - catzs->view = view; + if (catzs->view == NULL) { + dns_view_weakattach(view, &catzs->view); + } else if (catzs->view != view) { + dns_view_weakdetach(&catzs->view); + dns_view_weakattach(view, &catzs->view); + } } isc_result_t @@ -1034,6 +1039,9 @@ dns__catz_zones_destroy(dns_catz_zones_t *catzs) { isc_task_detach(&catzs->updater); isc_mutex_destroy(&catzs->lock); isc_refcount_destroy(&catzs->references); + if (catzs->view != NULL) { + dns_view_weakdetach(&catzs->view); + } isc_mem_putanddetach(&catzs->mctx, catzs, sizeof(*catzs)); }