[FFmpeg-devel] [PATCH] clear s->error in avio_read
    Fredrik Hubinette 
    hubbe at google.com
       
    Mon Mar 20 19:21:08 EET 2017
    
    
  
In some cases (when parsing OGG) non-fatal errors can happen, which
will cause s->error to be set. In most cases, this is not a problem beucase
s->error is not checked unless an actual error has occurred.  However,
when avio_read() fails to read more bytes, it checks s->error to decide if
it just reached the end of the file, or an error occurred. Since s->error is
not modified if no error occurred, this is not reliable unless we first
clear
s->error before reading.
---
 libavformat/aviobuf.c   | 2 ++
 2 files changed, 7 insertions(+)
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index bf7e5f85a0..35ca3a3b4f 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -605,6 +605,8 @@ int avio_read(AVIOContext *s, unsigned char *buf, int
size)
 {
     int len, size1;
+    s->error = 0;
+
     size1 = size;
     while (size > 0) {
         len = FFMIN(s->buf_end - s->buf_ptr, size);
--
2.12.0.367.g23dc2f6d3c-goog
    
    
More information about the ffmpeg-devel
mailing list