mirror of https://github.com/openssl/openssl.git
crypto/pkcs7/pk7_smime.c: Add BIO_free() to avoid memory leak
Add BIO_free() to free tmpout if OPENSSL_malloc() fails to avoid memory leak.
Fixes: 8e70485
("RT3955: Reduce some stack usage")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27631)
This commit is contained in:
parent
0dc6ea55a1
commit
9882d389df
|
@ -333,10 +333,8 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
|
||||||
if (flags & PKCS7_TEXT) {
|
if (flags & PKCS7_TEXT) {
|
||||||
if (!SMIME_text(tmpout, out)) {
|
if (!SMIME_text(tmpout, out)) {
|
||||||
ERR_raise(ERR_LIB_PKCS7, PKCS7_R_SMIME_TEXT_ERROR);
|
ERR_raise(ERR_LIB_PKCS7, PKCS7_R_SMIME_TEXT_ERROR);
|
||||||
BIO_free(tmpout);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
BIO_free(tmpout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now Verify All Signatures */
|
/* Now Verify All Signatures */
|
||||||
|
@ -354,6 +352,8 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
if (flags & PKCS7_TEXT)
|
||||||
|
BIO_free(tmpout);
|
||||||
X509_STORE_CTX_free(cert_ctx);
|
X509_STORE_CTX_free(cert_ctx);
|
||||||
OPENSSL_free(buf);
|
OPENSSL_free(buf);
|
||||||
if (indata != NULL)
|
if (indata != NULL)
|
||||||
|
|
Loading…
Reference in New Issue