From: Mark Andrews Date: Mon, 6 Sep 2010 04:31:11 +0000 (+0000) Subject: 2949. [bug] dns_view_setnewzones() contained a memory leak if X-Git-Tag: v9.8.0-P1~456 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=02a211f4c4d86f283f9c94bc7e5ab07b547e49f4;p=thirdparty%2Fbind9.git 2949. [bug] dns_view_setnewzones() contained a memory leak if it was called multiple times. [RT #21942] --- diff --git a/CHANGES b/CHANGES index 437b606de47..c9b03e40291 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 1737a47b17f..3b71a4bcec8 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);