diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-12-10 15:21:19 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-12-19 18:33:38 +0100 |
commit | dbc819bd36c2dccde58ece3330a6f47434590c57 (patch) | |
tree | 9c66a7da0dc67a9b042113f2054e101b8f92fc4c /crypto | |
parent | 27764db49082d7a57ebe7030aca1ab11757abccd (diff) |
Fix a possible memory leak in ossl_x509_algor_md_to_mgf1
Add a missing check of the return code of X509_ALGOR_set0.
otherwise a memory leak may occur.
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22999)
(cherry picked from commit 493d6c9ab37b18b110c977a2bc896f06b18f6065)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asn1/x_algor.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/asn1/x_algor.c b/crypto/asn1/x_algor.c index c0a5f76803..2c4a8d4b4e 100644 --- a/crypto/asn1/x_algor.c +++ b/crypto/asn1/x_algor.c @@ -179,7 +179,11 @@ int ossl_x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md) *palg = X509_ALGOR_new(); if (*palg == NULL) goto err; - X509_ALGOR_set0(*palg, OBJ_nid2obj(NID_mgf1), V_ASN1_SEQUENCE, stmp); + if (!X509_ALGOR_set0(*palg, OBJ_nid2obj(NID_mgf1), V_ASN1_SEQUENCE, stmp)) { + X509_ALGOR_free(*palg); + *palg = NULL; + goto err; + } stmp = NULL; err: ASN1_STRING_free(stmp); |