]> git.sesse.net Git - vlc/commitdiff
Apply the same probes as is done in Open when checking other mkvs in
authorSigmund Augdal Helberg <sigmunau@videolan.org>
Tue, 1 May 2007 11:08:40 +0000 (11:08 +0000)
committerSigmund Augdal Helberg <sigmunau@videolan.org>
Tue, 1 May 2007 11:08:40 +0000 (11:08 +0000)
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

index 3e81018a81107894f7a19424a94e2def340e4e3f..6d526cf1f6e84b63d8c96eb6d6de89044c55cc71 100644 (file)
@@ -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() );
                             }
                         }