aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2022-03-07 17:05:57 +0100
committerMatt Caswell <matt@openssl.org>2022-03-10 14:23:48 +0000
commitc02fff5aecd4d002143a0e901f3dde3d14934a18 (patch)
tree37fb3b3e933bd286c0f8d5519ca25c4d9167d99e
parentd3602088603605f39993f03781163df2decf85e3 (diff)
downloadopenssl-c02fff5aecd4d002143a0e901f3dde3d14934a18.tar.gz
Avoid potential memory leak
Resolves #17827 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17828) (cherry picked from commit 175355923046921a689b500f7a72455f7095708f)
-rw-r--r--crypto/x509v3/v3_utl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c
index 40d8f31554..83a4bc8a06 100644
--- a/crypto/x509v3/v3_utl.c
+++ b/crypto/x509v3/v3_utl.c
@@ -538,8 +538,11 @@ static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email
return 0;
emtmp = OPENSSL_strndup((char *)email->data, email->length);
- if (emtmp == NULL)
+ if (emtmp == NULL) {
+ X509_email_free(*sk);
+ *sk = NULL;
return 0;
+ }
/* Don't add duplicates */
if (sk_OPENSSL_STRING_find(*sk, emtmp) != -1) {