avformat: avoid potential tmp_opts leak in ffurl_connect()

When options is NULL, ffurl_connect() creates a temporary dictionary
(tmp_opts). If the protocol_blacklist av_dict_set() fails after the
whitelist entry was inserted, the function returns without freeing
this dictionary.

Ensure tmp_opts is freed on this error path.

Signed-off-by: Huihui_Huang <hhhuang@smu.edu.sg>

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
huanghuihui0904
2026-03-16 17:07:48 +08:00
committed by Marton Balint
parent 2c71a28bf0
commit b40d91cad9
+6 -1
View File
@@ -239,7 +239,7 @@ int ffurl_connect(URLContext *uc, AVDictionary **options)
if ((err = av_dict_set(options, "protocol_whitelist", uc->protocol_whitelist, 0)) < 0)
return err;
if ((err = av_dict_set(options, "protocol_blacklist", uc->protocol_blacklist, 0)) < 0)
return err;
goto fail;
err =
uc->prot->url_open2 ? uc->prot->url_open2(uc,
@@ -260,6 +260,11 @@ int ffurl_connect(URLContext *uc, AVDictionary **options)
if (!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0)
uc->is_streamed = 1;
return 0;
fail:
if (options == &tmp_opts)
av_dict_free(&tmp_opts);
return err;
}
int ffurl_accept(URLContext *s, URLContext **c)