Commit 73160f1a authored by Cheng Sun's avatar Cheng Sun Committed by Jean-Baptiste Kempf

Fix crash in invalid mkv files

VirtualFromSegments can crash if the std::vector passed in is empty, which
can happen in corrupted files. This is just a simple check for this case,
making it fail elegantly rather than crashing
OK-ed-by: default avatarDenis Charmet <typx@dinauz.org>
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 2bb4972e
......@@ -634,12 +634,14 @@ void demux_sys_t::PreloadFamily( const matroska_segment_c & of_segment )
}
// preload all the linked segments for all preloaded segments
void demux_sys_t::PreloadLinked()
bool demux_sys_t::PreloadLinked()
{
size_t i, j;
virtual_segment_c *p_seg;
p_current_segment = VirtualFromSegments( &opened_segments );
if ( !p_current_segment )
return false;
used_segments.push_back( p_current_segment );
......@@ -679,10 +681,14 @@ void demux_sys_t::PreloadLinked()
}
// TODO decide which segment should be first used (VMG for DVD)
return true;
}
virtual_segment_c *demux_sys_t::VirtualFromSegments( std::vector<matroska_segment_c*> *p_segments ) const
{
if ( p_segments->empty() )
return NULL;
virtual_segment_c *p_result = new virtual_segment_c( p_segments );
return p_result;
}
......
......@@ -379,7 +379,7 @@ public:
virtual_chapter_c *FindChapter( int64_t i_find_uid, virtual_segment_c * & p_segment_found );
void PreloadFamily( const matroska_segment_c & of_segment );
void PreloadLinked();
bool PreloadLinked();
bool PreparePlayback( virtual_segment_c *p_new_segment );
matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false );
void JumpTo( virtual_segment_c & p_segment, virtual_chapter_c * p_chapter );
......
......@@ -234,9 +234,8 @@ static int Open( vlc_object_t * p_this )
p_sys->PreloadFamily( *p_segment );
}
p_sys->PreloadLinked();
if ( !p_sys->PreparePlayback( NULL ) )
if ( !p_sys->PreloadLinked() ||
!p_sys->PreparePlayback( NULL ) )
{
msg_Err( p_demux, "cannot use the segment" );
goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment