diff mbox

[FFmpeg-devel,2/2] avformat/aviobuf: Forward error codes in avio_seek

Message ID 20190514084949.57498-2-andreas.rheinhardt@gmail.com
State New
Headers show

Commit Message

Andreas Rheinhardt May 14, 2019, 8:49 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/aviobuf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer May 14, 2019, 9:44 a.m. UTC | #1
On Tue, May 14, 2019 at 10:49:49AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/aviobuf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

do you have some testcase for this ?

thanks

[...]
Andreas Rheinhardt May 14, 2019, 3:34 p.m. UTC | #2
Michael Niedermayer:
> On Tue, May 14, 2019 at 10:49:49AM +0200, Andreas Rheinhardt wrote:
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
>> ---
>>  libavformat/aviobuf.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> do you have some testcase for this ?
> 
> thanks
> 
Honestly, no. I just read the code.
(Btw: Thinking of the bigger picture, there is something even weirder:
If an error happens (i.e. an AVIOContext's error is set) and one
performs a successfull seek, then error will still be set, yet
eof_reached will be cleared, although the latter is supposed to be
always set when error is set, isn't it? The same thing can happen when
one calls avio_feof on the AVIOContext.)

- Andreas
diff mbox

Patch

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 5c01423a2e..2462b95b16 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -293,8 +293,11 @@  int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
                (!s->direct || !s->seek)) {
         while(s->pos < offset && !s->eof_reached)
             fill_buffer(s);
-        if (s->eof_reached)
+        if (s->eof_reached) {
+            if (s->error)
+                return s->error;
             return AVERROR_EOF;
+        }
         s->buf_ptr = s->buf_end - (s->pos - offset);
     } else if(!s->write_flag && offset1 < 0 && -offset1 < buffer_size>>1 && s->seek && offset > 0) {
         int64_t res;