]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix the abnormal branch memory leak in ssl_set_cert_and_key function
authorlan1120 <lanming@huawei.com>
Fri, 19 Sep 2025 10:45:30 +0000 (18:45 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 23 Sep 2025 14:36:23 +0000 (16:36 +0200)
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28619)

ssl/ssl_rsa.c

index a1ea7ed105d3f5c11a5c7777c6187fc18c5cbebe..d2b7b171c872b958d587b28bc49a104d42b39919 100644 (file)
@@ -1056,10 +1056,13 @@ static int ssl_set_cert_and_key(SSL *ssl, SSL_CTX *ctx, X509 *x509, EVP_PKEY *pr
         }
     }
 
-    if (!X509_up_ref(x509))
+    if (!X509_up_ref(x509)) {
+        OSSL_STACK_OF_X509_free(dup_chain);
         goto out;
+    }
 
     if (!EVP_PKEY_up_ref(privatekey)) {
+        OSSL_STACK_OF_X509_free(dup_chain);
         X509_free(x509);
         goto out;
     }