]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2949. [bug] dns_view_setnewzones() contained a memory leak if
authorMark Andrews <marka@isc.org>
Mon, 6 Sep 2010 04:31:11 +0000 (04:31 +0000)
committerMark Andrews <marka@isc.org>
Mon, 6 Sep 2010 04:31:11 +0000 (04:31 +0000)
                        it was called multiple times. [RT #21942]

CHANGES
lib/dns/view.c

diff --git a/CHANGES b/CHANGES
index 437b606de475209df6d1b4cb5a83dbc55822c7cd..c9b03e40291dee38a9351de4978405aab8377489 100644 (file)
--- 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.
index 1737a47b17f9425b1e856b5e83d33bea2ec0be72..3b71a4bcec8b472050535e339919f387568d8a77 100644 (file)
@@ -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);