[vlc-commits] demux: mp4: fix reading stss/stsh

Francois Cartegnie git at videolan.org
Sat May 24 17:28:59 CEST 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat May 24 16:49:36 2014 +0200| [b6b90af630decc3dc1fe7f21dd420a5ba53a45df] | committer: Francois Cartegnie

demux: mp4: fix reading stss/stsh

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

 modules/demux/mp4/libmp4.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 3e3716f..329d21d 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -2078,13 +2078,16 @@ static int MP4_ReadBox_stss( stream_t *p_stream, MP4_Box_t *p_box )
     if( unlikely( p_box->data.p_stss->i_sample_number == NULL ) )
         MP4_READBOX_EXIT( 0 );
 
-    for( unsigned int i = 0; (i < p_box->data.p_stss->i_entry_count )&&( i_read >= 4 ); i++ )
+    unsigned int i;
+    for( i = 0; (i < p_box->data.p_stss->i_entry_count )&&( i_read >= 4 ); i++ )
     {
 
         MP4_GET4BYTES( p_box->data.p_stss->i_sample_number[i] );
         /* XXX in libmp4 sample begin at 0 */
         p_box->data.p_stss->i_sample_number[i]--;
     }
+    if ( i < p_box->data.p_stss->i_entry_count )
+        p_box->data.p_stss->i_entry_count = i;
 
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream, "read box: \"stss\" entry-count %d",
@@ -2125,11 +2128,14 @@ static int MP4_ReadBox_stsh( stream_t *p_stream, MP4_Box_t *p_box )
         MP4_READBOX_EXIT( 0 );
     }
 
-    for( unsigned i = 0; (i < p_box->data.p_stss->i_entry_count )&&( i_read >= 8 ); i++ )
+    unsigned i;
+    for( i = 0; (i < p_box->data.p_stss->i_entry_count )&&( i_read >= 8 ); i++ )
     {
         MP4_GET4BYTES( p_box->data.p_stsh->i_shadowed_sample_number[i] );
         MP4_GET4BYTES( p_box->data.p_stsh->i_sync_sample_number[i] );
     }
+    if ( i < p_box->data.p_stss->i_entry_count )
+        p_box->data.p_stss->i_entry_count = i;
 
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream, "read box: \"stsh\" entry-count %d",



More information about the vlc-commits mailing list