db4030
From cfbb8a96570959a3d7471edbd8df559ea4e73123 Mon Sep 17 00:00:00 2001
db4030
From: Mark Andrews <marka@isc.org>
db4030
Date: Wed, 14 Nov 2018 15:17:48 +1100
db4030
Subject: [PATCH] free tmpzonename and restart_master
db4030
db4030
(cherry picked from commit 50714a9b35ce80bd8839a52106778d65b6d4d7ba)
db4030
(cherry picked from commit e409b8c6982a275e3fad960b2e66437890ff08e2)
db4030
---
db4030
 bin/nsupdate/nsupdate.c    | 14 ++++++++++++--
db4030
 lib/dns/include/dns/name.h |  5 +++++
db4030
 2 files changed, 17 insertions(+), 2 deletions(-)
db4030
db4030
diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c
db4030
index a0d0278635..7e241c17e9 100644
db4030
--- a/bin/nsupdate/nsupdate.c
db4030
+++ b/bin/nsupdate/nsupdate.c
db4030
@@ -158,8 +158,8 @@ static dns_fixedname_t fuserzone;
db4030
 static dns_fixedname_t fzname;
db4030
 static dns_name_t *userzone = NULL;
db4030
 static dns_name_t *zname = NULL;
db4030
-static dns_name_t tmpzonename;
db4030
-static dns_name_t restart_master;
db4030
+static dns_name_t tmpzonename = DNS_NAME_INITEMPTY;
db4030
+static dns_name_t restart_master = DNS_NAME_INITEMPTY;
db4030
 static dns_tsig_keyring_t *gssring = NULL;
db4030
 static dns_tsigkey_t *tsigkey = NULL;
db4030
 static dst_key_t *sig0key = NULL;
db4030
@@ -2415,6 +2415,8 @@ update_completed(isc_task_t *task, isc_event_t *event) {
db4030
 	if (usegsstsig) {
db4030
 		dns_name_free(&tmpzonename, gmctx);
db4030
 		dns_name_free(&restart_master, gmctx);
db4030
+		dns_name_init(&tmpzonename, 0);
db4030
+		dns_name_init(&restart_master, 0);
db4030
 	}
db4030
 	isc_event_free(&event);
db4030
 	done_update();
db4030
@@ -2830,6 +2832,8 @@ failed_gssrequest() {
db4030
 
db4030
 	dns_name_free(&tmpzonename, gmctx);
db4030
 	dns_name_free(&restart_master, gmctx);
db4030
+	dns_name_init(&tmpzonename, NULL);
db4030
+	dns_name_init(&restart_master, NULL);
db4030
 
db4030
 	done_update();
db4030
 }
db4030
@@ -3238,6 +3242,12 @@ cleanup(void) {
db4030
 		isc_mem_free(gmctx, realm);
db4030
 		realm = NULL;
db4030
 	}
db4030
+	if (dns_name_dynamic(&tmpzonename)) {
db4030
+		dns_name_free(&tmpzonename, gmctx);
db4030
+	}
db4030
+	if (dns_name_dynamic(&restart_master)) {
db4030
+		dns_name_free(&restart_master, gmctx);
db4030
+	}
db4030
 #endif
db4030
 
db4030
 	if (sig0key != NULL)
db4030
diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h
db4030
index be74667ccb..93ddacd80b 100644
db4030
--- a/lib/dns/include/dns/name.h
db4030
+++ b/lib/dns/include/dns/name.h
db4030
@@ -181,6 +181,11 @@ LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_wildcardname;
db4030
 	{NULL, NULL} \
db4030
 }
db4030
 
db4030
+#define DNS_NAME_INITEMPTY { \
db4030
+	DNS_NAME_MAGIC, NULL, 0, 0, 0, NULL, NULL, \
db4030
+	{ (void *)-1, (void *)-1 }, { NULL, NULL } \
db4030
+}
db4030
+
db4030
 /*%
db4030
  * Standard size of a wire format name
db4030
  */
db4030
-- 
db4030
2.21.1
db4030