demux:mkv: don't add seekpoints for tracks that don't exist
authorSteve Lhomme <robUx4@videolabs.io>
Wed, 2 Aug 2017 15:06:57 +0000 (17:06 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 2 Aug 2017 15:54:48 +0000 (17:54 +0200)
Fixes #18596

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

index 982792d..6baac94 100644 (file)
@@ -1204,7 +1204,10 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
 
             if( ksblock.IsKeyframe() )
             {
-                vars.obj->_seeker.add_seekpoint( ksblock.TrackNum(), SegmentSeeker::Seekpoint::TRUSTED, ksblock.GetElementPosition(), ksblock.GlobalTimecode() / 1000 );
+                tracks_map_t::iterator track_it;
+                bool const b_valid_track = !vars.obj->FindTrackByBlock( &track_it, NULL, &ksblock );
+                if (b_valid_track)
+                    vars.obj->_seeker.add_seekpoint( ksblock.TrackNum(), SegmentSeeker::Seekpoint::TRUSTED, ksblock.GetElementPosition(), ksblock.GlobalTimecode() / 1000 );
             }
         }
     };
@@ -1219,7 +1222,9 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
             vars.block->ReadData( vars.obj->es.I_O() );
             vars.block->SetParent( *vars.obj->cluster );
 
-            if( vars.obj->tracks.at( kblock.TrackNum() )->fmt.i_cat == SPU_ES )
+            tracks_map_t::iterator track_it;
+            bool const b_valid_track = !vars.obj->FindTrackByBlock( &track_it, &kblock, NULL );
+            if( b_valid_track && track_it->second->fmt.i_cat == SPU_ES )
             {
                 vars.obj->_seeker.add_seekpoint( kblock.TrackNum(), SegmentSeeker::Seekpoint::TRUSTED, kblock.GetElementPosition(), kblock.GlobalTimecode() / 1000 );
             }