Skip to content

Commit 33c4054

Browse files
Fix for CID 299748 memory leak in error case
1 parent ef50cb3 commit 33c4054

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

wolfcrypt/src/pkcs7.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6107,11 +6107,15 @@ static int wc_PKCS7_KariGenerateKEK(WC_PKCS7_KARI* kari, WC_RNG* rng,
61076107
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION != 2))) && \
61086108
!defined(HAVE_SELFTEST)
61096109
ret = wc_ecc_set_rng(kari->senderKey, rng);
6110-
if (ret != 0)
6110+
if (ret != 0) {
6111+
XFREE(secret, kari->heap, DYNAMIC_TYPE_PKCS7);
61116112
return ret;
6113+
}
61126114
ret = wc_ecc_set_rng(kari->recipKey, rng);
6113-
if (ret != 0)
6115+
if (ret != 0) {
6116+
XFREE(secret, kari->heap, DYNAMIC_TYPE_PKCS7);
61146117
return ret;
6118+
}
61156119
#else
61166120
(void)rng;
61176121
#endif

0 commit comments

Comments
 (0)