[FFmpeg-cvslog] matroskadec: Fix read-after-free in matroska_read_seek()

Xiaohan Wang git at videolan.org
Tue Feb 17 19:43:15 CET 2015


ffmpeg | branch: release/2.2 | Xiaohan Wang <xhwang at chromium.org> | Thu Nov  6 12:59:54 2014 -0800| [a9602c6cfbe6fa06ff97ad01c0ffa9ad5ccff30f] | committer: Vittorio Giovara

matroskadec: Fix read-after-free in matroska_read_seek()

In matroska_read_seek(), |tracks| is assigned at the begining of the
function. However, functions like matroska_parse_cues() could reallocate
the tracks and invalidate |tracks|.

This assigns |tracks| only before using it, so that it will not get
invalidated elsewhere.

Bug-Id: chromium/427266

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

 libavformat/matroskadec.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 8aae26c..22902e0 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2375,7 +2375,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
                               int64_t timestamp, int flags)
 {
     MatroskaDemuxContext *matroska = s->priv_data;
-    MatroskaTrack *tracks = matroska->tracks.elem;
+    MatroskaTrack *tracks = NULL;
     AVStream *st = s->streams[stream_index];
     int i, index, index_sub, index_min;
 
@@ -2404,6 +2404,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
         return 0;
 
     index_min = index;
+    tracks = matroska->tracks.elem;
     for (i=0; i < matroska->tracks.nb_elem; i++) {
         tracks[i].audio.pkt_cnt = 0;
         tracks[i].audio.sub_packet_cnt = 0;



More information about the ffmpeg-cvslog mailing list