demux/mkv: do not expose hidden chapters
authorFilip Roséen <filip@atch.se>
Sat, 23 Jul 2016 22:56:27 +0000 (00:56 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 4 Aug 2016 09:24:08 +0000 (11:24 +0200)
Given that the matroska format can contain hidden chapters (and that the
demuxer itself create such where it feels applicable), we should not expose
such chapters (as seekpoints) outside of the demuxer module.

This fixes the ticket 17202 by checking whether or not the
chapter should be displayed to the user, and only appends the item to the
title's seekpoint array if this is the case.

Close #17202

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/demux/mkv/virtual_segment.cpp

index 5d30d7e..b069ce8 100644 (file)
@@ -590,24 +590,23 @@ int virtual_chapter_c::PublishChapters( input_title_t & title, int & i_user_chap
 
     if ( ( p_chapter && p_chapter->b_display_seekpoint &&
          ( ( sub_vchapters.size() > 0 && i_mk_virtual_start_time != sub_vchapters[0]->i_mk_virtual_start_time) ||
-           sub_vchapters.size() == 0 ) ) || !p_chapter )
+           sub_vchapters.size() == 0 ) ) )
     {
-        seekpoint_t *sk = vlc_seekpoint_New();
+        if( p_chapter->b_user_display )
+        {
+            seekpoint_t *sk = vlc_seekpoint_New();
 
-        sk->i_time_offset = i_mk_virtual_start_time;
-        if( p_chapter )
+            sk->i_time_offset = i_mk_virtual_start_time;
             sk->psz_name = strdup( p_chapter->psz_name.c_str() );
-        else
-            sk->psz_name = strdup("dummy chapter");
 
-        /* A start time of '0' is ok. A missing ChapterTime element is ok, too, because '0' is its default value. */
-        title.i_seekpoint++;
-        title.seekpoint = (seekpoint_t**)xrealloc( title.seekpoint,
-                                 title.i_seekpoint * sizeof( seekpoint_t* ) );
-        title.seekpoint[title.i_seekpoint-1] = sk;
+            /* A start time of '0' is ok. A missing ChapterTime element is ok, too, because '0' is its default value. */
+            title.i_seekpoint++;
+            title.seekpoint = (seekpoint_t**)xrealloc( title.seekpoint,
+              title.i_seekpoint * sizeof( seekpoint_t* ) );
+            title.seekpoint[title.i_seekpoint-1] = sk;
 
-        if ( (p_chapter && p_chapter->b_user_display ) ||  !p_chapter )
             i_user_chapters++;
+        }
     }
     i_seekpoint_num = i_user_chapters;