From 832a202c47a246ed15e3edc6b05dfcfa7d82c4b2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 19 Feb 2016 11:17:22 +0100 Subject: protocols: make the list of protocols static Disallow other code to touch it directly, now it's only accessible through a blacklisting/whitelisting function. --- libavformat/avio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'libavformat/avio.c') diff --git a/libavformat/avio.c b/libavformat/avio.c index b4e57e9..a9a399a 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -138,6 +138,7 @@ int ffurl_connect(URLContext *uc, AVDictionary **options) int ffurl_alloc(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb) { + const URLProtocol **protocols; char proto_str[128], proto_nested[128], *ptr; size_t proto_len = strspn(filename, URL_SCHEME_CHARS); int i; @@ -152,13 +153,18 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags, if ((ptr = strchr(proto_nested, '+'))) *ptr = '\0'; - for (i = 0; ff_url_protocols[i]; i++) { - const URLProtocol *up = ff_url_protocols[i]; - if (!strcmp(proto_str, up->name)) + protocols = ffurl_get_protocols(NULL, NULL); + for (i = 0; protocols[i]; i++) { + const URLProtocol *up = protocols[i]; + if (!strcmp(proto_str, up->name)) { + av_freep(&protocols); return url_alloc_for_protocol(puc, up, filename, flags, int_cb); + } if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME && - !strcmp(proto_nested, up->name)) + !strcmp(proto_nested, up->name)) { + av_freep(&protocols); return url_alloc_for_protocol(puc, up, filename, flags, int_cb); + } } *puc = NULL; return AVERROR_PROTOCOL_NOT_FOUND; -- cgit v1.1