From 183720eb6efedcabe3db8643676e55a4d9d2896d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 7 Nov 2015 13:35:10 +0100 Subject: [PATCH] avformat/segafilm: Only add index entries when the stream exists Fixes null pointer dereference Fixes: cb02dfb163ac833c04cace3d7e35b160/signal_sigsegv_e55c49_6326_8f25619fc86a00b303c57b7778baf70a.cpk Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavformat/segafilm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 6aef48eba9..f59b45f6f9 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -241,11 +241,12 @@ static int film_read_header(AVFormatContext *s) film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF; film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1; video_frame_counter++; - av_add_index_entry(s->streams[film->video_stream_index], - film->sample_table[i].sample_offset, - film->sample_table[i].pts, - film->sample_table[i].sample_size, 0, - film->sample_table[i].keyframe); + if (film->video_type) + av_add_index_entry(s->streams[film->video_stream_index], + film->sample_table[i].sample_offset, + film->sample_table[i].pts, + film->sample_table[i].sample_size, 0, + film->sample_table[i].keyframe); } }