aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiaohan Wang <xhwang@chromium.org>2014-11-06 12:59:54 -0800
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-01-27 14:36:12 +0000
commit6222ee068eeb3d29a2bcc4a89ce31effdef5a061 (patch)
treeaf62598c670e81abb0de5bc895ad2e9739747e6f
parent306ee95088243fefa2dfcb5c355d439db75e2d2a (diff)
downloadffmpeg-6222ee068eeb3d29a2bcc4a89ce31effdef5a061.tar.gz
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
-rw-r--r--libavformat/matroskadec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 730285afdc..14b99150f6 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2222,7 +2222,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;
@@ -2251,6 +2251,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;