vlc_block_helper: fix offset peek
authorFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 21 Jul 2017 20:40:14 +0000 (22:40 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Fri, 21 Jul 2017 23:44:06 +0000 (01:44 +0200)
returned incomplete peeks

include/vlc_block_helper.h

index d4e9a4b..4071c2b 100644 (file)
@@ -231,13 +231,9 @@ static inline int block_SkipByte( block_bytestream_t *p_bytestream )
 static inline int block_PeekOffsetBytes( block_bytestream_t *p_bytestream,
     size_t i_peek_offset, uint8_t *p_data, size_t i_data )
 {
-    /* Check we have that much data, ignoring read offset */
-    if( p_bytestream->i_total < i_peek_offset ||
-        p_bytestream->i_total - i_peek_offset < i_data )
-    {
-        /* Not enough data, bail out */
+    const size_t i_remain = block_BytestreamRemaining( p_bytestream );
+    if( i_remain < i_data + i_peek_offset )
         return VLC_EGENERIC;
-    }
 
     /* Find the right place */
     size_t i_offset = p_bytestream->i_block_offset;