]> git.sesse.net Git - vlc/commitdiff
* prevent crashes when a stream is not opened correctly
authorSteve Lhomme <robux@videolan.org>
Sat, 3 Sep 2005 15:55:52 +0000 (15:55 +0000)
committerSteve Lhomme <robux@videolan.org>
Sat, 3 Sep 2005 15:55:52 +0000 (15:55 +0000)
include/vlc_stream.h
modules/demux/mkv.cpp

index 0de036c1088aeaa126e9c4257c30f26ac9911b47..fdaa37f2dd8b7228278dd5c9a2fd3a953e554286 100644 (file)
@@ -123,6 +123,9 @@ static inline int stream_Control( stream_t *s, int i_query, ... )
     va_list args;
     int     i_result;
 
+    if ( s == NULL )
+        return VLC_EGENERIC;
+
     va_start( args, i_query );
     i_result = s->pf_control( s, i_query, args );
     va_end( args );
index c4343220202a1598b91ea69641c2256db7049439..164861137e68942926ea6c9dacddf5f121f37e47 100644 (file)
@@ -1481,21 +1481,30 @@ static int Open( vlc_object_t * p_this )
 #endif
                     {
                         // test wether this file belongs to our family
-                        vlc_stream_io_callback *p_file_io = new vlc_stream_io_callback( stream_UrlNew( p_demux, s_filename.c_str()), VLC_TRUE );
-                        EbmlStream *p_estream = new EbmlStream(*p_file_io);
-
-                        p_stream = p_sys->AnalyseAllSegmentsFound( p_estream );
-                        if ( p_stream == NULL )
+                        stream_t *p_file_stream = stream_UrlNew( p_demux, s_filename.c_str());
+                        if ( p_file_stream != NULL )
                         {
-                            msg_Dbg( p_demux, "the file '%s' will not be used", s_filename.c_str() );
-                            delete p_estream;
-                            delete p_file_io;
+                            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);
+
+                            p_stream = p_sys->AnalyseAllSegmentsFound( p_estream );
+
+                            if ( p_stream == NULL )
+                            {
+                                msg_Dbg( p_demux, "the file '%s' will not be used", s_filename.c_str() );
+                                delete p_estream;
+                                delete p_file_io;
+                            }
+                            else
+                            {
+                                p_stream->p_in = p_file_io;
+                                p_stream->p_es = p_estream;
+                                p_sys->streams.push_back( p_stream );
+                            }
                         }
                         else
                         {
-                            p_stream->p_in = p_file_io;
-                            p_stream->p_es = p_estream;
-                            p_sys->streams.push_back( p_stream );
+                            msg_Dbg( p_demux, "the file '%s' cannot be opened", s_filename.c_str() );
                         }
                     }
                 }
@@ -3324,6 +3333,8 @@ size_t vlc_stream_io_callback::write( const void *p_buffer, size_t i_size )
 }
 uint64 vlc_stream_io_callback::getFilePointer( void )
 {
+    if ( s == NULL )
+        return 0;
     return stream_Tell( s );
 }
 void vlc_stream_io_callback::close( void )