[vlc-commits] demux: mp4: fix potential endless loop

Francois Cartegnie git at videolan.org
Tue Aug 13 15:45:32 CEST 2019


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Aug 13 15:20:42 2019 +0200| [1fff012916dc579ecd53a592140d115ebd50aea2] | committer: Francois Cartegnie

demux: mp4: fix potential endless loop

(cherry picked from commit 5de914227402e7ed7653cc5700c1e6c155d2428b)

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

 modules/demux/mp4/mp4.c | 8 +++++++-
 modules/demux/mp4/mp4.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 9a70272678..c8755e6df6 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -4413,6 +4413,10 @@ static int DemuxMoof( demux_t *p_demux )
     if( p_sys->i_pcr == VLC_TS_INVALID )
         es_out_SetPCR( p_demux->out, VLC_TS_0 + i_nztime );
 
+    /* Set per track read state */
+    for( unsigned i = 0; i < p_sys->i_tracks; i++ )
+        p_sys->track[i].context.i_temp = VLC_DEMUXER_SUCCESS;
+
     /* demux up to increment amount of data on every track, or just set pcr if empty data */
     for( ;; )
     {
@@ -4426,7 +4430,8 @@ static int DemuxMoof( demux_t *p_demux )
 
             if( !tk_tmp->b_ok || tk_tmp->b_chapters_source ||
                (!tk_tmp->b_selected && !p_sys->b_seekable) ||
-                tk_tmp->context.runs.i_current >= tk_tmp->context.runs.i_count )
+                tk_tmp->context.runs.i_current >= tk_tmp->context.runs.i_count ||
+                tk_tmp->context.i_temp != VLC_DEMUXER_SUCCESS )
                 continue;
 
             /* At least still have data to demux on this or next turns */
@@ -4465,6 +4470,7 @@ static int DemuxMoof( demux_t *p_demux )
 
             int i_ret = FragDemuxTrack( p_demux, tk, i_max_preload );
 
+            tk->context.i_temp = i_ret;
             if( i_ret == VLC_DEMUXER_SUCCESS )
                 i_status = VLC_DEMUXER_SUCCESS;
             else if( i_ret == VLC_DEMUXER_FATAL )
diff --git a/modules/demux/mp4/mp4.h b/modules/demux/mp4/mp4.h
index 99cb9bbb5e..c0d04ce9df 100644
--- a/modules/demux/mp4/mp4.h
+++ b/modules/demux/mp4/mp4.h
@@ -163,6 +163,7 @@ typedef struct
         uint64_t i_trun_sample;
         uint64_t i_trun_sample_pos;
 
+        int i_temp;
     } context;
 
     /* ASF packets handling */



More information about the vlc-commits mailing list