[vlc-commits] demux: libmp4: continue after failed contained atom

Francois Cartegnie git at videolan.org
Mon Sep 5 09:31:14 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Sep  4 19:24:00 2016 +0200| [1f3537e9805f4d626bf065c91be70811852fa9b2] | committer: Francois Cartegnie

demux: libmp4: continue after failed contained atom

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

 modules/demux/mp4/libmp4.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 091cc8c..5fcf256 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -295,11 +295,14 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
         return 0;
     }
 
+    uint64_t i_last_pos = 0; /* used to detect read failure loops */
     const uint64_t i_end = p_container->i_pos + p_container->i_size;
     MP4_Box_t *p_box = NULL;
     bool b_onexclude = false;
+    bool b_continue;
     do
     {
+        b_continue = false;
         if ( p_container->i_size )
         {
             const uint64_t i_tell = vlc_stream_Tell( p_stream );
@@ -318,6 +321,7 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
         b_onexclude = false; /* If stopped due exclude list */
         if( (p_box = MP4_ReadBoxRestricted( p_stream, p_container, NULL, excludelist, &b_onexclude )) )
         {
+            b_continue = true;
             p_box->i_index = i_index;
             for(size_t i=0; stoplist && stoplist[i]; i++)
             {
@@ -326,17 +330,23 @@ static int MP4_ReadBoxContainerChildrenIndexed( stream_t *p_stream,
             }
         }
 
-        if ( p_container->i_size )
+        const uint64_t i_tell = vlc_stream_Tell( p_stream );
+        if ( p_container->i_size && i_tell >= i_end )
         {
-            const uint64_t i_tell = vlc_stream_Tell( p_stream );
-            if( i_tell >= i_end )
-            {
-                assert( i_tell == i_end );
+            assert( i_tell == i_end );
+            break;
+        }
+
+        if ( !p_box )
+        {
+            /* Continue with next if box fails to load */
+            if( i_last_pos == i_tell )
                 break;
-            }
+            i_last_pos = i_tell;
+            b_continue = true;
         }
 
-    } while( p_box );
+    } while( b_continue );
 
     /* Always move to end of container */
     if ( !b_onexclude &&  p_container->i_size )



More information about the vlc-commits mailing list