From d993f37a1bb8ac6ba4094b82767c596c031edc49 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 24 Jun 2026 17:22:26 +0200 Subject: [PATCH] avformat/avio: propagate prefer_libcurl preference from parent URLContext Since this is consumed by e.g. protocols which open inner protocols. This would normally be propagated by the `av_opt_copy` call, but as this check happens *before* the inner URLContext is even allocated, we're forced to propagate the options manually. Sponsored-by: nxtedition AB Signed-off-by: Niklas Haas --- libavformat/avio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 3e8f32d899..22b4948481 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -375,7 +375,8 @@ extern const URLProtocol ff_libcurl_protocol; /* Decide whether an http(s) URL should be routed to the libcurl protocol instead * of the native one. Controlled by the per-open "prefer_libcurl" option. */ -static int prefer_libcurl(const char *filename, AVDictionary **options) +static int prefer_libcurl(const char *filename, AVDictionary **options, + URLContext *parent) { URLContext dummy = { .av_class = &url_context_class }; AVDictionaryEntry *e; @@ -384,6 +385,9 @@ static int prefer_libcurl(const char *filename, AVDictionary **options) !av_strstart(filename, "https://", NULL)) return 0; + if (parent && parent->prefer_libcurl) + return 1; + if (!options || !(e = av_dict_get(*options, "prefer_libcurl", NULL, 0))) return 0; if (av_opt_set(&dummy, "prefer_libcurl", e->value, 0) < 0) @@ -405,7 +409,7 @@ static int url_open_whitelist(URLContext **puc, const char *filename, int flags, #if CONFIG_LIBCURL_PROTOCOL /* The option itself is applied to the URLContext further down; here it only * picks the protocol, before the context exists. */ - if (prefer_libcurl(filename, options)) + if (prefer_libcurl(filename, options, parent)) ret = url_alloc_for_protocol(puc, &ff_libcurl_protocol, filename, flags, int_cb); else