[vlc-devel] [PATCH] demux/avformat: fix 17575: fix return-value of IORead

Filip Roséen filip at atch.se
Tue Nov 1 14:01:53 CET 2016


av_read_frame expects 0 to be returned on end-of-file, and negative
values are reserved for fatal stream-errors. The previous
implementation would return -1 upon EOF (vlc_stream_Read returning 0),
causing premature EOF from modules/demux/avformat/demux.c:Demux.

These changes make sure that we honor the contract associated with the
read-callback, and that we only return -1 if there is a fatal error.

fixes #17574
---
 modules/demux/avformat/demux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index f962862..4f81ad8 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -1119,7 +1119,7 @@ static int IORead( void *opaque, uint8_t *buf, int buf_size )
     demux_t *p_demux = opaque;
     if( buf_size < 0 ) return -1;
     int i_ret = vlc_stream_Read( p_demux->s, buf, buf_size );
-    return i_ret ? i_ret : -1;
+    return i_ret >= 0 ? i_ret : -1;
 }
 
 static int64_t IOSeek( void *opaque, int64_t offset, int whence )
-- 
2.10.1



More information about the vlc-devel mailing list