[vlc-commits] demux/mkv: fix memory-leak during seek

Filip Roséen git at videolan.org
Fri Sep 23 16:03:29 CEST 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Fri Sep 23 15:43:09 2016 +0200| [8d9946527b4b364a2109653b25905c9881426b06] | committer: Thomas Guillem

demux/mkv: fix memory-leak during seek

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

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 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();



More information about the vlc-commits mailing list