[vlc-devel] [PATCH 1/8] demux/mkv: fix memory-leak during seek

Filip Roséen filip at atch.se
Fri Sep 23 15:43:09 CEST 2016


The diff should speak for itself, but we should of course not break
out of the loop before we had the opportunity to free the allocated
memory within it.

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

diff --git a/modules/demux/mkv/matroska_segment_seeker.cpp b/modules/demux/mkv/matroska_segment_seeker.cpp
index de18242..73a2d16 100644
--- a/modules/demux/mkv/matroska_segment_seeker.cpp
+++ b/modules/demux/mkv/matroska_segment_seeker.cpp
@@ -326,18 +326,18 @@ SegmentSeeker::index_unsearched_range( matroska_segment_c& ms, Range search_area
             block_pts = block->GlobalTimecode() / 1000;
         }
 
-        if( ! ms.FindTrackByBlock( &i_track, block, simpleblock ) )
+        bool const b_valid_track = !ms.FindTrackByBlock( &i_track, block, simpleblock );
+
+        delete block;
+
+        if( b_valid_track )
         {
             if( b_key_picture )
-            {
                 add_seekpoint( i_track->first, Seekpoint::TRUSTED, block_pos, block_pts );
-            }
 
             if( max_pts < block_pts )
                 break;
         }
-
-        delete block;
     }
 
     search_area.end = ms.es.I_O().getFilePointer();
-- 
2.10.0



More information about the vlc-devel mailing list