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