Skip to content

Commit

Permalink
Fix a possible memory leak in ossl_x509_algor_md_to_mgf1
Browse files Browse the repository at this point in the history
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 #22999)

(cherry picked from commit 493d6c9)
  • Loading branch information
bernd-edlinger authored and t8m committed Dec 19, 2023
1 parent 27764db commit dbc819b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crypto/asn1/x_algor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dbc819b

Please sign in to comment.