Skip to content

Commit 554ebc2

Browse files
committed
coverity: fix double free of encryptedContent.
1 parent 115507e commit 554ebc2

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
@@ -13698,6 +13698,7 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
1369813698
/* free memory, zero out keys */
1369913699
ForceZero(encryptedContent, (word32)encryptedContentSz);
1370013700
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
13701+
encryptedContent = NULL;
1370113702
ForceZero(decryptedKey, MAX_ENCRYPTED_KEY_SZ);
1370213703
#ifdef WOLFSSL_SMALL_STACK
1370313704
XFREE(decryptedKey, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
@@ -13726,8 +13727,11 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
1372613727
}
1372713728
#else
1372813729
if (ret < 0) {
13729-
ForceZero(encryptedContent, (word32)encryptedContentSz);
13730-
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
13730+
if (encryptedContent != NULL) {
13731+
ForceZero(encryptedContent, (word32)encryptedContentSz);
13732+
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
13733+
encryptedContent = NULL;
13734+
}
1373113735
ForceZero(decryptedKey, MAX_ENCRYPTED_KEY_SZ);
1373213736
}
1373313737
#endif

0 commit comments

Comments
 (0)