PR #22235 opened by Nariman-Sayed
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22235
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22235.patch

tls_openssl: fix memory leak in cert_from_pem_string

When PEM_read_bio_X509 fails, BIO was not freed, causing memory leaks.
Add BIO_free(mem) before returning NULL to prevent resource leak.


>From e75a1348325f9728b2420843d8dee177941f757b Mon Sep 17 00:00:00 2001
From: Nariman-Sayed <[email protected]>
Date: Sat, 21 Feb 2026 01:19:25 +0200
Subject: [PATCH] tls_openssl: fix memory leak in cert_from_pem_string

---
 libavformat/tls_openssl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 0ae0980cc3..b00ce7cc3a 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -407,6 +407,7 @@ static X509 *cert_from_pem_string(const char *pem_str)
     X509 *cert = PEM_read_bio_X509(mem, NULL, NULL, NULL);
     if (!cert) {
         av_log(NULL, AV_LOG_ERROR, "Failed to parse certificate from 
string\n");
+        BIO_free(mem);
         return NULL;
     }
 
-- 
2.52.0

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

Reply via email to