diff mbox series

[FFmpeg-devel,1/2] libavformat/aviobuf: Forward error from avio_read in ffio_read_size()

Message ID 20201031092957.14996-1-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/2] libavformat/aviobuf: Forward error from avio_read in ffio_read_size() | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Oct. 31, 2020, 9:29 a.m. UTC
Suggested-by: Andreas Rheinhardt
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/aviobuf.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Andreas Rheinhardt Oct. 31, 2020, 2:18 p.m. UTC | #1
Michael Niedermayer:
> Suggested-by: Andreas Rheinhardt
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/aviobuf.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 80a5a565a4..3cc440e4e7 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -686,6 +686,8 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
>  int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
>  {
>      int ret = avio_read(s, buf, size);
> +    if (ret < 0 && ret != AVERROR_EOF)
> +        return ret;
>      if (ret != size)
>          return AVERROR_INVALIDDATA;
>      return ret;
> 
Maybe first check for ret == size. After all, that is supposed to be the
common case.

- Andreas
Michael Niedermayer Nov. 4, 2020, 8:09 a.m. UTC | #2
On Sat, Oct 31, 2020 at 03:18:26PM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Suggested-by: Andreas Rheinhardt
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/aviobuf.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> > index 80a5a565a4..3cc440e4e7 100644
> > --- a/libavformat/aviobuf.c
> > +++ b/libavformat/aviobuf.c
> > @@ -686,6 +686,8 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
> >  int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
> >  {
> >      int ret = avio_read(s, buf, size);
> > +    if (ret < 0 && ret != AVERROR_EOF)
> > +        return ret;
> >      if (ret != size)
> >          return AVERROR_INVALIDDATA;
> >      return ret;
> > 
> Maybe first check for ret == size. After all, that is supposed to be the
> common case.

ok, will do

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 80a5a565a4..3cc440e4e7 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -686,6 +686,8 @@  int avio_read(AVIOContext *s, unsigned char *buf, int size)
 int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
 {
     int ret = avio_read(s, buf, size);
+    if (ret < 0 && ret != AVERROR_EOF)
+        return ret;
     if (ret != size)
         return AVERROR_INVALIDDATA;
     return ret;