Fix a bug preventing files without segment duration
authorDenis Charmet <typx@dinauz.org>
Tue, 1 Nov 2011 14:42:43 +0000 (15:42 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 1 Nov 2011 14:55:57 +0000 (15:55 +0100)
And fix the crash of http://streams.videolan.org/issues/mkv/invalid_EBML_number_size_tag.mkv

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/demux/mkv/demux.cpp
modules/demux/mkv/virtual_segment.cpp

index ac399d4..6ebcaef 100644 (file)
@@ -697,6 +697,8 @@ bool demux_sys_t::PreparePlayback( virtual_segment_c *p_new_segment )
         p_current_segment = p_new_segment;
         i_current_title = p_new_segment->i_sys_title;
     }
+    if( !p_current_segment->CurrentSegment() )
+        return false;
     if( !p_current_segment->CurrentSegment()->b_cues )
         msg_Warn( &p_current_segment->CurrentSegment()->sys.demuxer, "no cues/empty cues found->seek won't be precise" );
 
index 7f7e191..ccd462f 100644 (file)
@@ -351,7 +351,9 @@ virtual_chapter_c* virtual_edition_c::getChapterbyTimecode( int64_t time )
 {
     for( size_t i = 0; i < chapters.size(); i++ )
     {
-        if( time >= chapters[i]->i_virtual_start_time && time < chapters[i]->i_virtual_stop_time )
+        if( time >= chapters[i]->i_virtual_start_time &&
+            ( chapters[i]->i_virtual_stop_time < 0 || time < chapters[i]->i_virtual_stop_time ) )
+            /*with the current implementation only the last chapter can have a negative virtual_stop_time*/
             return chapters[i]->getSubChapterbyTimecode( time );
     }