[vlc-devel] [PATCH 1/5] demux/mkv: fix assert on infinite clusters

Filip Roséen filip at atch.se
Sat Oct 22 04:54:08 CEST 2016


A cluster can have an infinite size, and if so the result of invoking
KaxCluster::GetEndPosition is undefined. These changes simply make
sure that we do not query clusters for their size, if they are not
finite in size.

fixes #17537
---
 modules/demux/mkv/matroska_segment_seeker.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment_seeker.cpp b/modules/demux/mkv/matroska_segment_seeker.cpp
index 73a2d16..dcab581 100644
--- a/modules/demux/mkv/matroska_segment_seeker.cpp
+++ b/modules/demux/mkv/matroska_segment_seeker.cpp
@@ -68,7 +68,9 @@ SegmentSeeker::add_cluster( KaxCluster * const p_cluster )
         /* fpos     */ p_cluster->GetElementPosition(),
         /* pts      */ mtime_t( p_cluster->GlobalTimecode() / INT64_C( 1000 ) ),
         /* duration */ mtime_t( -1 ),
-        /* size     */ p_cluster->GetEndPosition() - p_cluster->GetElementPosition()
+        /* size     */ p_cluster->IsFiniteSize()
+            ? p_cluster->GetEndPosition() - p_cluster->GetElementPosition()
+            : UINT64_MAX
     };
 
     add_cluster_position( cinfo.fpos );
@@ -425,7 +427,8 @@ SegmentSeeker::mkv_jump_to( matroska_segment_c& ms, fptr_t fpos )
         ms.ep->reconstruct( &ms.es, ms.segment, &ms.sys.demuxer );
     }
 
-    while( ms.cluster == NULL || ms.cluster->GetEndPosition() < fpos )
+    while( ms.cluster == NULL || (
+          ms.cluster->IsFiniteSize() && ms.cluster->GetEndPosition() < fpos ) )
     {
         if( !( ms.cluster = static_cast<KaxCluster*>( ms.ep->Get() ) ) )
         {
-- 
2.10.0



More information about the vlc-devel mailing list