From 1950629ffade5531d102639261a31321f8cdbb39 Mon Sep 17 00:00:00 2001
From: Aram Sargsyan <aram@isc.org>
Date: Fri, 9 Dec 2022 12:41:38 +0000
Subject: [PATCH] Fix dns_fwdtable_addfwd() error path cleanup bug

Free 'sizeof(dns_forwarder_t)' bytes of memory instead of
'sizeof(dns_sockaddr_t)' bytes, because `fwd` is a pointer
to a 'dns_forwarder_t' type structure.

Conflict: NA
Reference: https://gitlab.isc.org/isc-projects/bind9/-/commit/1950629ffade5531d102639261a31321f8cdbb39

(cherry picked from commit 0cc1b06d98676ab66200d388c48c3cd615aa0109)
---
 lib/dns/forward.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dns/forward.c b/lib/dns/forward.c
index 53d0c5ee4e..c7c54cddce 100644
--- a/lib/dns/forward.c
+++ b/lib/dns/forward.c
@@ -103,7 +103,7 @@ cleanup:
 	while (!ISC_LIST_EMPTY(forwarders->fwdrs)) {
 		fwd = ISC_LIST_HEAD(forwarders->fwdrs);
 		ISC_LIST_UNLINK(forwarders->fwdrs, fwd, link);
-		isc_mem_put(fwdtable->mctx, fwd, sizeof(isc_sockaddr_t));
+		isc_mem_put(fwdtable->mctx, fwd, sizeof(dns_forwarder_t));
 	}
 	isc_mem_put(fwdtable->mctx, forwarders, sizeof(dns_forwarders_t));
 	return (result);
-- 
2.23.0
