[FFmpeg-devel] [PATCH] lavf/avio: check that the protocol supports the open mode.

Nicolas George nicolas.george at normalesup.org
Wed Feb 13 13:31:41 CET 2013


Fix trac ticket #2139.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavformat/avio.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 6d8a8bb..b00cc9d 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -119,6 +119,16 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
     if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())
         return AVERROR(EIO);
 #endif
+    if ((flags & AVIO_FLAG_READ) && !up->url_read) {
+        av_log(NULL, AV_LOG_ERROR,
+               "Impossible to open the '%s' protocol for reading\n", up->name);
+        return AVERROR(EIO);
+    }
+    if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {
+        av_log(NULL, AV_LOG_ERROR,
+               "Impossible to open the '%s' protocol for writing\n", up->name);
+        return AVERROR(EIO);
+    }
     uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);
     if (!uc) {
         err = AVERROR(ENOMEM);
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list