Skip to content

Commit 2cb1781

Browse files
authored
Merge pull request #9922 from Frauschi/f-450
Fix memory leak in error case within RsaMGF1
2 parents cd2386c + 9c2bb3d commit 2cb1781

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

wolfcrypt/src/rsa.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,10 @@ static int RsaMGF1(enum wc_HashType hType, byte* seed, word32 seedSz,
985985
#endif
986986
if (ret != 0) {
987987
/* check for if dynamic memory was needed, then free */
988+
#ifdef WOLFSSL_SMALL_STACK_CACHE
989+
wc_HashFree(hash, hType);
990+
XFREE(hash, heap, DYNAMIC_TYPE_DIGEST);
991+
#endif
988992
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
989993
if (tmpF) {
990994
XFREE(tmp, heap, DYNAMIC_TYPE_RSA_BUFFER);

0 commit comments

Comments
 (0)