Commit f5e4a37c authored by Dennis van Amerongen's avatar Dennis van Amerongen

* modules/demux/mkv.cpp: backport [19988] apply open probes when checking .mkv...

* modules/demux/mkv.cpp: backport [19988] apply open probes when checking .mkv in same folder; fix memleak and fix crash when there are multiple .mkv and one of them is corrupt or incomplete
parent d375796c
......@@ -1519,8 +1519,16 @@ static int Open( vlc_object_t * p_this )
#endif
{
// test wether this file belongs to our family
uint8_t *p_peek;
bool file_ok = false;
stream_t *p_file_stream = stream_UrlNew( p_demux, s_filename.c_str());
if ( p_file_stream != NULL )
/* peek the begining */
if( p_file_stream &&
stream_Peek( p_file_stream, &p_peek, 4 ) >= 4
&& p_peek[0] == 0x1a && p_peek[1] == 0x45 &&
p_peek[2] == 0xdf && p_peek[3] == 0xa3 ) file_ok = true;
if ( file_ok )
{
vlc_stream_io_callback *p_file_io = new vlc_stream_io_callback( p_file_stream, VLC_TRUE );
EbmlStream *p_estream = new EbmlStream(*p_file_io);
......@@ -1542,6 +1550,9 @@ static int Open( vlc_object_t * p_this )
}
else
{
if( p_file_stream ) {
stream_Delete( p_file_stream );
}
msg_Dbg( p_demux, "the file '%s' cannot be opened", s_filename.c_str() );
}
}
......
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