[vlc-devel] [PATCH 1/2] demux/mkv: abort matroska_segment_c::PreloadClusters on end-of-file

Filip Roséen filip at atch.se
Mon Feb 20 18:10:19 CET 2017


The previous implementation assumed that every mkv had at least one
non-Cluster element following the Clusters; meaning that it would
potentially try to continue parsing even though the parser reached a
state where no more elements can be read at the current level.

We should of course stop the affected loop if no more elements can be
read, as these changes make sure we do.
---
 modules/demux/mkv/matroska_segment.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 016748b049..9aca1da6fd 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -509,8 +509,12 @@ bool matroska_segment_c::PreloadClusters(uint64 i_cluster_pos)
         while (payload.stop_parsing == false)
         {
             EbmlParser parser ( &es, segment, &sys.demuxer, var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
+            EbmlElement* el = parser.Get();
 
-            ClusterHandler::Dispatcher().send( parser.Get(), ClusterHandler::Payload( payload ) );
+            if( el == NULL )
+                break;
+
+            ClusterHandler::Dispatcher().send( el, ClusterHandler::Payload( payload ) );
         }
     }
 
-- 
2.11.1



More information about the vlc-devel mailing list