This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 9bc4109b23 avformat/tls_openssl: fix memory leak in 
cert_from_pem_string
9bc4109b23 is described below

commit 9bc4109b23d8a6cad3982f481952764cafef0e35
Author:     Nariman-Sayed <[email protected]>
AuthorDate: Sun Feb 22 05:45:46 2026 +0200
Commit:     Jack Lau <[email protected]>
CommitDate: Sun Feb 22 22:39:43 2026 +0000

    avformat/tls_openssl: fix memory leak in cert_from_pem_string
    
    When PEM_read_bio_X509 fails, BIO was not freed, causing memory leak.
    Free BIO before returning NULL to prevent resource leak.
---
 libavformat/tls_openssl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 0ae0980cc3..65d486567d 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -398,17 +398,16 @@ static EVP_PKEY *pkey_from_pem_string(const char 
*pem_str, int is_priv)
  */
 static X509 *cert_from_pem_string(const char *pem_str)
 {
+    X509 *cert = NULL;
     BIO *mem = BIO_new_mem_buf(pem_str, -1);
     if (!mem) {
         av_log(NULL, AV_LOG_ERROR, "BIO_new_mem_buf failed\n");
         return NULL;
     }
 
-    X509 *cert = PEM_read_bio_X509(mem, NULL, NULL, NULL);
-    if (!cert) {
+    cert = PEM_read_bio_X509(mem, NULL, NULL, NULL);
+    if (!cert)
         av_log(NULL, AV_LOG_ERROR, "Failed to parse certificate from 
string\n");
-        return NULL;
-    }
 
     BIO_free(mem);
     return cert;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to