avio: Fix sanity checks in ffurl_read*
authorMartin Storsjö <martin@martin.st>
Wed, 20 Apr 2011 14:09:46 +0000 (17:09 +0300)
committerAnton Khirnov <anton@khirnov.net>
Wed, 20 Apr 2011 15:00:11 +0000 (17:00 +0200)
This fixes e.g. reading data over HTTP, where the underlying
socket is set to read/write.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavformat/avio.c

index 074d3ee..0702aff 100644 (file)
@@ -289,14 +289,14 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
 
 int ffurl_read(URLContext *h, unsigned char *buf, int size)
 {
-    if (h->flags & AVIO_FLAG_WRITE)
+    if (!(h->flags & AVIO_FLAG_READ))
         return AVERROR(EIO);
     return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read);
 }
 
 int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
 {
-    if (h->flags & AVIO_FLAG_WRITE)
+    if (!(h->flags & AVIO_FLAG_READ))
         return AVERROR(EIO);
     return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read);
 }