Commit 490a3ebf authored by Xiaohan Wang's avatar Xiaohan Wang Committed by 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
parent d75190aa
...@@ -2541,7 +2541,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, ...@@ -2541,7 +2541,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags) int64_t timestamp, int flags)
{ {
MatroskaDemuxContext *matroska = s->priv_data; MatroskaDemuxContext *matroska = s->priv_data;
MatroskaTrack *tracks = matroska->tracks.elem; MatroskaTrack *tracks = NULL;
AVStream *st = s->streams[stream_index]; AVStream *st = s->streams[stream_index];
int i, index, index_sub, index_min; int i, index, index_sub, index_min;
...@@ -2571,6 +2571,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, ...@@ -2571,6 +2571,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
return 0; return 0;
index_min = index; index_min = index;
tracks = matroska->tracks.elem;
for (i = 0; i < matroska->tracks.nb_elem; i++) { for (i = 0; i < matroska->tracks.nb_elem; i++) {
tracks[i].audio.pkt_cnt = 0; tracks[i].audio.pkt_cnt = 0;
tracks[i].audio.sub_packet_cnt = 0; tracks[i].audio.sub_packet_cnt = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment