[vlc-devel] commit: Ignore invalid blocks (on broken files). (Laurent Aimar )

git version control git at videolan.org
Wed Aug 20 00:51:31 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Aug 20 00:50:20 2008 +0200| [ce718de21f000a5dda416960a2b7dffdacabd9a2] | committer: Laurent Aimar 

Ignore invalid blocks (on broken files).
workarounds a bug in KaxBlockVirtual implementation (close #1079).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce718de21f000a5dda416960a2b7dffdacabd9a2
---

 modules/demux/mkv.cpp |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/modules/demux/mkv.cpp b/modules/demux/mkv.cpp
index bf127da..436174b 100644
--- a/modules/demux/mkv.cpp
+++ b/modules/demux/mkv.cpp
@@ -1769,6 +1769,23 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, int64_t *pi_ref1, int64
         if( (el = ep->Get()) == NULL && pp_block != NULL )
 #endif
         {
+            /* Check blocks validity to protect againts broken files */
+            if(
+#if LIBMATROSKA_VERSION >= 0x000800
+                pp_simpleblock && pp_simpleblock->TrackNum() >= tracks.size() ||
+#else
+                false ||
+#endif
+                pp_block && pp_block->TrackNum() >= tracks.size() )
+            {
+                delete pp_block;
+#if LIBMATROSKA_VERSION >= 0x000800
+                pp_simpleblock = NULL;
+#endif
+                pp_block = NULL;
+                continue;
+            }
+
             /* update the index */
 #define idx p_indexes[i_index - 1]
             if( i_index > 0 && idx.i_time == -1 )
@@ -3843,6 +3860,19 @@ void EbmlParser::Reset( demux_t *p_demux )
     mb_dummy = config_GetInt( p_demux, "mkv-use-dummy" );
 }
 
+#if LIBMATROSKA_VERSION >= 0x000800
+/* This function workarounds a bug in KaxBlockVirtual implementation */
+class KaxBlockVirtualWorkaround : public KaxBlockVirtual
+{
+public:
+    void Fix()
+    {
+        if( Data == DataBlock )
+            SetBuffer( NULL, 0 );
+    }
+};
+#endif
+
 EbmlElement *EbmlParser::Get( void )
 {
     int i_ulev = 0;
@@ -3864,6 +3894,10 @@ EbmlElement *EbmlParser::Get( void )
         m_el[mi_level]->SkipData( *m_es, m_el[mi_level]->Generic().Context );
         if( !mb_keep )
         {
+#if LIBMATROSKA_VERSION >= 0x000800
+            if( MKV_IS_ID( m_el[mi_level], KaxBlockVirtual ) )
+                static_cast<KaxBlockVirtualWorkaround*>(m_el[mi_level])->Fix();
+#endif
             delete m_el[mi_level];
         }
         mb_keep = false;




More information about the vlc-devel mailing list