]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Avoid potential memory leak
authorDmitry Belyavskiy <beldmit@gmail.com>
Mon, 7 Mar 2022 16:05:57 +0000 (17:05 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 10 Mar 2022 14:23:48 +0000 (14:23 +0000)
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)

crypto/x509v3/v3_utl.c

index 40d8f315549cbd8ebfe9ca74ead570d2e3fad53c..83a4bc8a06b53a8f4c9220c45e28bc9ef4d97880 100644 (file)
@@ -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) {