[vlc-commits] demux: mkv: do not use the file if there's no usable stream/segment

Steve Lhomme git at videolan.org
Wed Aug 14 18:24:19 CEST 2019


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul 24 12:01:20 2019 +0200| [041ed2b98e04e8139eb556803d449fa8420ca5b0] | committer: Hugo Beauzée-Luyssen

demux: mkv: do not use the file if there's no usable stream/segment

Ref #22474

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
(cherry picked from commit dfa50b418711da81e941f059c4704c4a1a21ffab)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

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

 modules/demux/mkv/demux.cpp | 4 +++-
 modules/demux/mkv/demux.hpp | 2 +-
 modules/demux/mkv/mkv.cpp   | 6 +++++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index 7823ca1940..3efb97f0b5 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -699,7 +699,7 @@ bool demux_sys_t::PreloadLinked()
     return true;
 }
 
-void demux_sys_t::FreeUnused()
+bool demux_sys_t::FreeUnused()
 {
     auto sIt = std::remove_if(begin(streams), end(streams), [](const matroska_stream_c* p_s) {
         return !p_s->isUsed();
@@ -715,6 +715,8 @@ void demux_sys_t::FreeUnused()
     for (auto it = sgIt; it != end(opened_segments); ++it)
         delete *it;
     opened_segments.erase(sgIt, end(opened_segments));
+
+    return !streams.empty() && !opened_segments.empty();
 }
 
 bool demux_sys_t::PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date )
diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
index 69f3882a36..314e1066a8 100644
--- a/modules/demux/mkv/demux.hpp
+++ b/modules/demux/mkv/demux.hpp
@@ -382,7 +382,7 @@ public:
 
     void PreloadFamily( const matroska_segment_c & of_segment );
     bool PreloadLinked();
-    void FreeUnused();
+    bool FreeUnused();
     bool PreparePlayback( virtual_segment_c & new_vsegment, mtime_t i_mk_date );
     bool AnalyseAllSegmentsFound( demux_t *p_demux, matroska_stream_c *, bool b_initial = false );
     void JumpTo( virtual_segment_c & vsegment, virtual_chapter_c & vchapter );
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 6b9a818fd8..5cb3f7ea95 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -244,7 +244,11 @@ static int Open( vlc_object_t * p_this )
         goto error;
     }
 
-    p_sys->FreeUnused();
+    if (!p_sys->FreeUnused())
+    {
+        msg_Err( p_demux, "no usable segment" );
+        goto error;
+    }
 
     p_sys->InitUi();
 



More information about the vlc-commits mailing list