[vlc-commits] mkv: fix return values of ebml callbacks

Thomas Guillem git at videolan.org
Wed Feb 10 20:00:28 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Feb 10 19:54:46 2016 +0100| [565dd315b8855cd364d4757806d96a0014e5c879] | committer: Thomas Guillem

mkv: fix return values of ebml callbacks

stream_Read can return -1 in case of error while ebml read callback returns an
unsigned.

This caused an infinite loop when VLC was interrupted.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=565dd315b8855cd364d4757806d96a0014e5c879
---

 modules/demux/mkv/stream_io_callback.cpp |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mkv/stream_io_callback.cpp b/modules/demux/mkv/stream_io_callback.cpp
index 555cc9b..4f2306b 100644
--- a/modules/demux/mkv/stream_io_callback.cpp
+++ b/modules/demux/mkv/stream_io_callback.cpp
@@ -41,7 +41,8 @@ uint32 vlc_stream_io_callback::read( void *p_buffer, size_t i_size )
     if( i_size <= 0 || mb_eof )
         return 0;
 
-    return stream_Read( s, p_buffer, i_size );
+    int i_ret = stream_Read( s, p_buffer, i_size );
+    return i_ret < 0 ? 0 : i_ret;
 }
 
 void vlc_stream_io_callback::setFilePointer(int64_t i_offset, seek_mode mode )
@@ -100,7 +101,7 @@ uint64 vlc_stream_io_callback::toRead( void )
 
     i_size = stream_Size( s );
 
-    if( i_size == 0 )
+    if( i_size <= 0 )
         return UINT64_MAX;
 
     return (uint64) i_size - stream_Tell( s );



More information about the vlc-commits mailing list