diff --git a/CHANGES b/CHANGES index 437b606de4..c9b03e4029 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2949. [bug] dns_view_setnewzones() contained a memory leak if + it was called multiple times. [RT #21942] + 2948. [port] MacOS: provide a mechanism to configure the test interfaces at reboot. See bin/tests/system/README for details. diff --git a/lib/dns/view.c b/lib/dns/view.c index 1737a47b17..3b71a4bcec 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: view.c,v 1.168 2010/08/12 04:04:14 each Exp $ */ +/* $Id: view.c,v 1.169 2010/09/06 04:31:11 marka Exp $ */ /*! \file */ @@ -1635,6 +1635,16 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx, REQUIRE((cfgctx != NULL && cfg_destroy != NULL) || !allow); #ifdef BIND9 + if (view->new_zone_file != NULL) { + isc_mem_free(view->mctx, view->new_zone_file); + view->new_zone_file = NULL; + } + + if (view->new_zone_config != NULL) { + view->cfg_destroy(&view->new_zone_config); + view->cfg_destroy = NULL; + } + if (allow) { char buffer[ISC_SHA256_DIGESTSTRINGLENGTH + sizeof(NZF)]; isc_sha256_data((void *)view->name, strlen(view->name), buffer); @@ -1643,16 +1653,6 @@ dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx, view->new_zone_file = isc_mem_strdup(view->mctx, buffer); view->new_zone_config = cfgctx; view->cfg_destroy = cfg_destroy; - } else { - if (view->new_zone_file != NULL) { - isc_mem_free(view->mctx, view->new_zone_file); - view->new_zone_file = NULL; - } - - if (view->new_zone_config != NULL) { - view->cfg_destroy(&view->new_zone_config); - view->cfg_destroy = NULL; - } } #else UNUSED(allow);