[vlc-commits] ttml demux: Gracefully handle span with no time attributes

Hugo Beauzée-Luyssen git at videolan.org
Wed Sep 14 18:39:46 CEST 2016


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Sep 14 16:06:47 2016 +0200| [d97c8e0712dd1d2980848fba530bd8010026d6d1] | committer: Hugo Beauzée-Luyssen

ttml demux: Gracefully handle span with no time attributes

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

 modules/demux/ttml.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/modules/demux/ttml.c b/modules/demux/ttml.c
index c4c8708..af71c2b 100644
--- a/modules/demux/ttml.c
+++ b/modules/demux/ttml.c
@@ -451,18 +451,23 @@ static int ParseTimeOnSpan( demux_sys_t* p_sys, char* psz_text )
             if( unlikely( p_node == NULL ) )
                 goto error;
 
-            pp_subtitles[i_nb_span] = malloc( sizeof( *pp_subtitles[i_nb_span] ) );
-            if( unlikely( pp_subtitles[i_nb_span] == NULL ) )
+            if( ReadAttrNode( p_sys->p_reader, p_node, psz_node_name ) != VLC_SUCCESS )
             {
                 ClearNode( p_node );
                 goto error;
             }
-
-            if( ReadAttrNode( p_sys->p_reader, p_node, psz_node_name ) != VLC_SUCCESS )
+            if( p_node->psz_begin == NULL || p_node->psz_end == NULL )
+            {
+                ClearNode( p_node );
+                continue;
+            }
+            pp_subtitles[i_nb_span] = malloc( sizeof( *pp_subtitles[i_nb_span] ) );
+            if( unlikely( pp_subtitles[i_nb_span] == NULL ) )
             {
                 ClearNode( p_node );
                 goto error;
             }
+
             pp_subtitles[i_nb_span]->psz_text = NodeToStr( p_node );
             if( pp_subtitles[i_nb_span] == NULL )
             {
@@ -476,10 +481,14 @@ static int ParseTimeOnSpan( demux_sys_t* p_sys, char* psz_text )
         }
         else if( i_type == XML_READER_TEXT )
         {
+            if ( pp_subtitles[i_nb_span] == NULL )
+                continue;
             pp_subtitles[i_nb_span]->psz_text = Append( pp_subtitles[i_nb_span]->psz_text, "%s", psz_node_name );
         }
         else if( i_type == XML_READER_ENDELEM )
         {
+            if ( pp_subtitles[i_nb_span] == NULL )
+                continue;
             pp_subtitles[i_nb_span]->psz_text = Append( pp_subtitles[i_nb_span]->psz_text, "</%s>", psz_node_name );
             i_nb_span++;
             subtitle_t** pp_tmp = realloc( pp_subtitles, ( i_nb_span + 1 ) * sizeof( *pp_subtitles ) );



More information about the vlc-commits mailing list