Adam Tkac bbe577
Written-by: Adam Tkac <atkac@redhat.com>
Adam Tkac bbe577
Adam Tkac bbe577
diff -up bind-9.5.0a6/contrib/dbus/dbus_mgr.c.leak bind-9.5.0a6/contrib/dbus/dbus_mgr.c
Adam Tkac bbe577
--- bind-9.5.0a6/contrib/dbus/dbus_mgr.c.leak	2007-05-10 07:47:02.000000000 +0200
Adam Tkac bbe577
+++ bind-9.5.0a6/contrib/dbus/dbus_mgr.c	2007-10-18 13:32:19.000000000 +0200
Adam Tkac bbe577
@@ -167,6 +167,9 @@ dbus_mgr_init_dbus(ns_dbus_mgr_t *);
Adam Tkac bbe577
 static isc_result_t
Adam Tkac bbe577
 dbus_mgr_record_initial_fwdtable(ns_dbus_mgr_t *);
Adam Tkac bbe577
 
Adam Tkac bbe577
+static
Adam Tkac bbe577
+dns_fwdtable_t *dbus_mgr_get_fwdtable(void);
Adam Tkac bbe577
+
Adam Tkac bbe577
 static void
Adam Tkac bbe577
 dbus_mgr_free_initial_fwdtable(ns_dbus_mgr_t *);
Adam Tkac bbe577
 
Adam Tkac bbe577
@@ -272,6 +275,8 @@ dbus_mgr_create
Adam Tkac bbe577
     return ISC_R_SUCCESS;
Adam Tkac bbe577
 
Adam Tkac bbe577
  cleanup_mgr:
Adam Tkac bbe577
+    if ( dbus_mgr_get_fwdtable() != NULL)
Adam Tkac bbe577
+	dbus_mgr_free_initial_fwdtable (mgr);
Adam Tkac bbe577
     if( mgr->task != 0L )
Adam Tkac bbe577
 	isc_task_detach(&(mgr->task));
Adam Tkac bbe577
     isc_mem_put(mctx, mgr, sizeof(*mgr));
Adam Tkac bbe577
@@ -623,7 +628,7 @@ static void dbus_mgr_record_initial_forw
Adam Tkac bbe577
 
Adam Tkac bbe577
     dns_name_init(&(ifwdr->dn), NULL);
Adam Tkac bbe577
     if( dns_name_dupwithoffsets(name, mgr->mctx, &(ifwdr->dn)) != ISC_R_SUCCESS )
Adam Tkac bbe577
-	return;
Adam Tkac bbe577
+	goto namedup_err;
Adam Tkac bbe577
 
Adam Tkac bbe577
     ISC_LIST_INIT(ifwdr->sa);
Adam Tkac bbe577
     
Adam Tkac bbe577
@@ -634,14 +639,27 @@ static void dbus_mgr_record_initial_forw
Adam Tkac bbe577
     {
Adam Tkac bbe577
 	nsa = isc_mem_get(mgr->mctx, sizeof(isc_sockaddr_t));
Adam Tkac bbe577
 	if( nsa == 0L ) 
Adam Tkac bbe577
-	    return;
Adam Tkac bbe577
+	    goto nsa_err;
Adam Tkac bbe577
 	*nsa = *sa;
Adam Tkac bbe577
 	ISC_LINK_INIT(nsa, link);
Adam Tkac bbe577
 	ISC_LIST_APPEND(ifwdr->sa, nsa, link);
Adam Tkac bbe577
     }
Adam Tkac bbe577
     ISC_LINK_INIT(ifwdr, link);
Adam Tkac bbe577
     tsearch( ifwdr, &(mgr->ifwdt), dbus_mgr_ifwdr_comparator);
Adam Tkac bbe577
-} 
Adam Tkac bbe577
+
Adam Tkac bbe577
+    return;
Adam Tkac bbe577
+
Adam Tkac bbe577
+nsa_err:
Adam Tkac bbe577
+    while ( (sa = ISC_LIST_HEAD (ifwdr->sa)) != NULL) {
Adam Tkac bbe577
+	ISC_LIST_UNLINK (ifwdr->sa, sa, link);
Adam Tkac bbe577
+	isc_mem_put (mgr->mctx, sa, sizeof (*sa));
Adam Tkac bbe577
+    }
Adam Tkac bbe577
+
Adam Tkac bbe577
+namedup_err:
Adam Tkac bbe577
+    isc_mem_put (mgr->mctx, ifwdr, sizeof (*ifwdr));
Adam Tkac bbe577
+
Adam Tkac bbe577
+    return;
Adam Tkac bbe577
+}
Adam Tkac bbe577
 
Adam Tkac bbe577
 static isc_result_t
Adam Tkac bbe577
 dbus_mgr_record_initial_fwdtable( ns_dbus_mgr_t *mgr )