diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index d47fa0f4378..914a5e3dd05 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -985,6 +985,10 @@ static int RsaMGF1(enum wc_HashType hType, byte* seed, word32 seedSz, #endif if (ret != 0) { /* check for if dynamic memory was needed, then free */ +#ifdef WOLFSSL_SMALL_STACK_CACHE + wc_HashFree(hash, hType); + XFREE(hash, heap, DYNAMIC_TYPE_DIGEST); +#endif #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC) if (tmpF) { XFREE(tmp, heap, DYNAMIC_TYPE_RSA_BUFFER);