avio: Fix sanity checks in ffurl_read*

Message ID 1303308586-21894-1-git-send-email-martin@martin.st
State Committed
Commit 26f6b8c571bcff7b325c7d6cc226c625dd465f8e
Headers show

Commit Message

Martin Storsjö April 20, 2011, 2:09 p.m.
This fixes e.g. reading data over HTTP, where the underlying
socket is set to read/write.
---
 libavformat/avio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Ronald Bultje April 20, 2011, 2:15 p.m. | #1
Hi,

On Wed, Apr 20, 2011 at 10:09 AM, Martin Storsjö <martin@martin.st> wrote:
> This fixes e.g. reading data over HTTP, where the underlying
> socket is set to read/write.
> ---
>  libavformat/avio.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index 074d3ee..0702aff 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -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);
>  }
> --
> 1.7.3.1

Looks good.

Ronald

Patch

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 074d3ee..0702aff 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -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);
 }