wolfcrypt/src/port/kcapi/kcapi_hmac.c: fix memory leak in wc_HmacSetKey() (fixes #4731).

This commit is contained in:
Daniel Pouzzner
2022-01-07 12:40:31 -06:00
parent b97894c617
commit bbc9bc5e2c

View File

@ -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;
}