PR #26168 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26168
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26168.patch

httpproxy has no priv_data_class, so ffurl_closep() never calls
av_opt_free() on its context and the AVOption fields filled in by
http_read_header() leak.

Declare the class so av_opt_free() releases those. cookie_dict and
new_location are not AVOptions and stay allocated, so free them in
http_proxy_close().

Fix fate-httpproxy-tunnel-eof failure.

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 4bea59df2bda41814155947ab158b2b099c6a9c4 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Wed, 18 Nov 2026 20:00:58 +0800
Subject: [PATCH] avformat/http: free the reply data of httpproxy connections

httpproxy has no priv_data_class, so ffurl_closep() never calls
av_opt_free() on its context and the AVOption fields filled in by
http_read_header() leak.

Declare the class so av_opt_free() releases those. cookie_dict and
new_location are not AVOptions and stay allocated, so free them in
http_proxy_close().

Fix fate-httpproxy-tunnel-eof failure.
---
 libavformat/http.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/http.c b/libavformat/http.c
index 786201c4ae4..a213f019d51 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -2544,6 +2544,8 @@ static int http_proxy_close(URLContext *h)
     HTTPContext *s = h->priv_data;
     if (s->hd)
         ffurl_closep(&s->hd);
+    av_dict_free(&s->cookie_dict);
+    av_freep(&s->new_location);
     return 0;
 }
 
@@ -2662,6 +2664,8 @@ static int http_proxy_read(URLContext *h, uint8_t *buf, 
int size)
     return ffurl_read(s->hd, buf, size);
 }
 
+HTTP_CLASS(httpproxy);
+
 const URLProtocol ff_httpproxy_protocol = {
     .name                = "httpproxy",
     .url_open            = http_proxy_open,
@@ -2670,6 +2674,7 @@ const URLProtocol ff_httpproxy_protocol = {
     .url_close           = http_proxy_close,
     .url_get_file_handle = http_get_file_handle,
     .priv_data_size      = sizeof(HTTPContext),
+    .priv_data_class     = &httpproxy_context_class,
     .flags               = URL_PROTOCOL_FLAG_NETWORK,
 };
 #endif /* CONFIG_HTTPPROXY_PROTOCOL */
-- 
2.54.0

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

Reply via email to