diff --git a/wolfcrypt/src/pwdbased.c b/wolfcrypt/src/pwdbased.c index e0edf6e3a..a5200d8de 100644 --- a/wolfcrypt/src/pwdbased.c +++ b/wolfcrypt/src/pwdbased.c @@ -198,8 +198,10 @@ int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt, if (buffer == NULL) return MEMORY_E; hmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_HMAC); - if (buffer == NULL) + if (hmac == NULL) { + XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; + } #endif ret = wc_HmacInit(hmac, NULL, INVALID_DEVID);