From d0c92a31a997d8c2fa48dd3a2ed90b11e54cfabf Mon Sep 17 00:00:00 2001
From: Mark Andrews <marka@isc.org>
Date: Fri, 17 Feb 2023 11:44:45 +1100
Subject: [PATCH] In hmac_createctx free ctx on isc_hmac_init failure

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

(cherry picked from commit d22257a370c69060e17a466db7698c96e23526b5)
---
 lib/dns/hmac_link.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/dns/hmac_link.c b/lib/dns/hmac_link.c
index d839f1123b..2872ff2c89 100644
--- a/lib/dns/hmac_link.c
+++ b/lib/dns/hmac_link.c
@@ -170,6 +170,7 @@ hmac_createctx(const isc_md_type_t *type, const dst_key_t *key,
 	result = isc_hmac_init(ctx, hkey->key, isc_md_type_get_block_size(type),
 			       type);
 	if (result != ISC_R_SUCCESS) {
+		isc_hmac_free(ctx);
 		return (DST_R_UNSUPPORTEDALG);
 	}
 
-- 
2.23.0
