From bbc9bc5e2c21e7a8403d7ff443fb95c88e863685 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 7 Jan 2022 12:40:31 -0600 Subject: [PATCH] wolfcrypt/src/port/kcapi/kcapi_hmac.c: fix memory leak in wc_HmacSetKey() (fixes #4731). --- wolfcrypt/src/port/kcapi/kcapi_hmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/port/kcapi/kcapi_hmac.c b/wolfcrypt/src/port/kcapi/kcapi_hmac.c index 5d4538d3a..4e96839fc 100644 --- a/wolfcrypt/src/port/kcapi/kcapi_hmac.c +++ b/wolfcrypt/src/port/kcapi/kcapi_hmac.c @@ -102,7 +102,7 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length) const char* ciphername = NULL; if ((hmac == NULL || (key == NULL && length != 0))) { - ret = BAD_FUNC_ARG; + return BAD_FUNC_ARG; } #ifdef HAVE_FIPS @@ -183,7 +183,7 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length) hmac->macType = type; } - if (ret == 0 && hmac->handle == NULL) { + if (hmac->handle != NULL) { kcapi_md_destroy(hmac->handle); hmac->handle = NULL; }