diff --git a/src/ssl.c b/src/ssl.c index 1a34d798f..4bd9e1b5e 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -15613,8 +15613,8 @@ WOLFSSL_EVP_PKEY* wolfSSL_X509_get_pubkey(WOLFSSL_X509* x509) if (wolfSSL_RSA_LoadDer_ex(key->rsa, (const unsigned char*)key->pkey.ptr, key->pkey_sz, WOLFSSL_RSA_LOAD_PUBLIC) != SSL_SUCCESS) { - XFREE(key, x509->heap, DYNAMIC_TYPE_PUBLIC_KEY); wolfSSL_RSA_free(key->rsa); + XFREE(key, x509->heap, DYNAMIC_TYPE_PUBLIC_KEY); return NULL; } } diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 500296088..d4ebf7b4d 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -10885,8 +10885,10 @@ static int SignCert(int requestSz, int sType, byte* buffer, word32 buffSz, sigSz = MakeSignature(certSignCtx, buffer, requestSz, certSignCtx->sig, MAX_ENCODED_SIG_SZ, rsaKey, eccKey, ed25519Key, rng, sType, heap); - if (sigSz == WC_PENDING_E) + if (sigSz == WC_PENDING_E) { + XFREE(certSignCtx->sig, heap, DYNAMIC_TYPE_TMP_BUFFER); return sigSz; + } if (sigSz >= 0) { if (requestSz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz) diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 5e7af23da..bbd85b608 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -5048,6 +5048,7 @@ int wc_PKCS7_DecodeEncryptedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz, /* go back and check the version now that attribs have been processed */ if ((haveAttribs == 0 && version != 0) || (haveAttribs == 1 && version != 2) ) { + XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7); WOLFSSL_MSG("Wrong PKCS#7 EncryptedData version"); return ASN_VERSION_E; }