From cbc9069af619cb0e57ca00fa1ab808a8e3d563ac Mon Sep 17 00:00:00 2001 From: Sigmund Augdal Helberg Date: Tue, 1 May 2007 11:08:40 +0000 Subject: [PATCH] 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 --- modules/demux/mkv.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/demux/mkv.cpp b/modules/demux/mkv.cpp index 3e81018a81..6d526cf1f6 100644 --- a/modules/demux/mkv.cpp +++ b/modules/demux/mkv.cpp @@ -1520,8 +1520,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); @@ -1543,6 +1551,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() ); } } -- 2.39.2