[vlc-devel] [PATCH 8/9] demux: mkv: add missing error-checks

Filip Roséen filip at atch.se
Mon Jul 16 05:19:56 CEST 2018


Prevent potential null-pointer dereferences.
---
 modules/demux/mkv/virtual_segment.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index 02e39ec0b0..aade7e7a45 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -520,7 +520,7 @@ bool virtual_segment_c::Seek( demux_t & demuxer, vlc_tick_t i_mk_date,
         /* 1st, we need to know in which chapter we are */
         p_vchapter = CurrentEdition()->getChapterbyTimecode( i_mk_date );
 
-    if ( p_vchapter != NULL )
+    if ( p_vchapter != NULL && CurrentEdition() )
     {
         vlc_tick_t i_mk_time_offset = p_vchapter->i_mk_virtual_start_time - ( ( p_vchapter->p_chapter )? p_vchapter->p_chapter->i_start_time : 0 );
         if (CurrentEdition()->b_ordered)
@@ -599,6 +599,9 @@ int virtual_chapter_c::PublishChapters( input_title_t & title, int & i_user_chap
         {
             seekpoint_t *sk = vlc_seekpoint_New();
 
+            if( unlikely( !sk ) )
+                return 0;
+
             sk->i_time_offset = i_mk_virtual_start_time;
             if (chap_name != "")
                 sk->psz_name = strdup( chap_name.c_str() );
@@ -629,6 +632,10 @@ int virtual_edition_c::PublishChapters( input_title_t & title, int & i_user_chap
         vchapters[0]->i_mk_virtual_start_time && p_edition && !p_edition->b_hidden )
     {
         seekpoint_t *sk = vlc_seekpoint_New();
+
+        if( unlikely( !sk ) )
+            return 0;
+
         sk->i_time_offset = 0;
         sk->psz_name = strdup( p_edition->str_name.c_str() );
 
-- 
2.18.0



More information about the vlc-devel mailing list