Memory allocation failure testing fixes

Fixes for test code to cleanup on failure properly.
pkcs7.c: when streaming, free the decrypting content when adding data to
the stream fails.
This commit is contained in:
Sean Parkinson
2025-07-01 11:01:07 +10:00
parent 6c8ab11f5f
commit 574de4b234
5 changed files with 106 additions and 23 deletions

View File

@@ -12659,8 +12659,13 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in,
case WC_PKCS7_ENV_5:
#ifndef NO_PKCS7_STREAM
if ((ret = wc_PKCS7_AddDataToStream(pkcs7, in, inSz,
pkcs7->stream->expected, &pkiMsg, &idx)) != 0) {
if (ret != WC_NO_ERR_TRACE(WC_PKCS7_WANT_READ_E)) {
wc_PKCS7_StreamGetVar(pkcs7, &encOID, NULL, NULL);
wc_PKCS7_DecryptContentFree(pkcs7, encOID, pkcs7->heap);
}
return ret;
}