[vlc-commits] demux: subtitle: fix sami loop (fix #18785)

Francois Cartegnie git at videolan.org
Mon Sep 11 11:30:23 CEST 2017


vlc/vlc-2.2 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Sep 10 15:57:16 2017 +0200| [65a0243621bd26f52c5ff6f6485c9e030fafae3e] | committer: Francois Cartegnie

demux: subtitle: fix sami loop (fix #18785)

happens when a start= is on same line

backport of 4378d5f91ef54e5d75e95a13580f11bed16d79d7

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

 modules/demux/subtitle.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 3e40f28065..f5634e8d75 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -166,6 +166,10 @@ struct demux_sys_t
         float f_total;
         float f_factor;
     } mpsub;
+    struct
+    {
+        char *psz_start;
+    } sami;
 };
 
 static int  ParseMicroDvd   ( demux_t *, subtitle_t *, int );
@@ -258,6 +262,7 @@ static int Open ( vlc_object_t *p_this )
 
     p_sys->jss.b_inited       = false;
     p_sys->mpsub.b_inited     = false;
+    p_sys->sami.psz_start     = NULL;
 
     /* Get the FPS */
     f_fps = var_CreateGetFloat( p_demux, "sub-original-fps" ); /* FIXME */
@@ -1255,7 +1260,9 @@ static int  ParseSami( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
     char text[8192]; /* Arbitrary but should be long enough */
 
     /* search "Start=" */
-    if( !( s = ParseSamiSearch( txt, NULL, "Start=" ) ) )
+    s = ParseSamiSearch( txt, p_sys->sami.psz_start, "Start=" );
+    p_sys->sami.psz_start = NULL;
+    if( !s )
         return VLC_EGENERIC;
 
     /* get start value */
@@ -1271,7 +1278,6 @@ static int  ParseSami( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
 
     i_text = 0;
     text[0] = '\0';
-    const char *psz_startline = s;
     /* now get all txt until  a "Start=" line */
     for( ;; )
     {
@@ -1288,10 +1294,9 @@ static int  ParseSami( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
             {
                 c = '\n';
             }
-            else if( strcasestr( s, "Start=" ) &&
-                     psz_startline != s )
+            else if( strcasestr( s, "Start=" ) )
             {
-                TextPreviousLine( txt );
+                p_sys->sami.psz_start = s;
                 break;
             }
             s = ParseSamiSearch( txt, s, ">" );



More information about the vlc-commits mailing list