Apply the same probes as is done in Open when checking other mkvs in

the same dir in order to weed out invalid files before calling
libmatroska. Fixes #1158 and a memleak in that area
parent 7a710cb6
...@@ -1520,8 +1520,16 @@ static int Open( vlc_object_t * p_this ) ...@@ -1520,8 +1520,16 @@ static int Open( vlc_object_t * p_this )
#endif #endif
{ {
// test wether this file belongs to our family // 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()); 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 ); 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); EbmlStream *p_estream = new EbmlStream(*p_file_io);
...@@ -1543,6 +1551,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -1543,6 +1551,9 @@ static int Open( vlc_object_t * p_this )
} }
else else
{ {
if( p_file_stream ) {
stream_Delete( p_file_stream );
}
msg_Dbg( p_demux, "the file '%s' cannot be opened", s_filename.c_str() ); 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