[vlc-commits] demux: subtitle: fix divbyzero

Francois Cartegnie git at videolan.org
Tue Jan 24 17:11:25 CET 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jan 24 17:10:28 2017 +0100| [83e21b1d08f4b43ad12e8d811751d69918a52ee3] | committer: Francois Cartegnie

demux: subtitle: fix divbyzero

can crash with start = -1 and stop = 0

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

 modules/demux/subtitle.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 498807c..e1d20da 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -564,12 +564,7 @@ static int Open ( vlc_object_t *p_this )
     p_sys->subtitles.i_current = 0;
     p_sys->i_length = 0;
     if( p_sys->subtitles.i_count > 0 )
-    {
         p_sys->i_length = p_sys->subtitles.p_array[p_sys->subtitles.i_count-1].i_stop;
-        /* +1 to avoid 0 */
-        if( p_sys->i_length <= 0 )
-            p_sys->i_length = p_sys->subtitles.p_array[p_sys->subtitles.i_count-1].i_start+1;
-    }
 
     /* *** add subtitle ES *** */
     if( p_sys->props.i_type == SUB_TYPE_SSA1 ||
@@ -678,7 +673,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             {
                 *pf = 1.0;
             }
-            else if( p_sys->subtitles.i_count > 0 )
+            else if( p_sys->subtitles.i_count > 0 && p_sys->i_length )
             {
                 *pf = p_sys->i_next_demux_date - var_GetInteger( p_demux->obj.parent, "spu-delay" );
                 if( *pf < 0 )



More information about the vlc-commits mailing list