From 9c569ef7129d2e2972a5caa9cc01899a502b4bbf Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Thu, 24 Mar 2011 00:28:19 +0100 Subject: [PATCH] matroskadec: check that pointers were initialized before accessing them Signed-off-by: Aurelien Jacobs Signed-off-by: Anton Khirnov --- libavformat/matroskadec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 0fa94a16d5..9c11c71e1f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1084,19 +1084,21 @@ static void matroska_convert_tags(AVFormatContext *s) if (tags[i].target.attachuid) { MatroskaAttachement *attachment = matroska->attachments.elem; for (j=0; jattachments.nb_elem; j++) - if (attachment[j].uid == tags[i].target.attachuid) + if (attachment[j].uid == tags[i].target.attachuid + && attachment[j].stream) matroska_convert_tag(s, &tags[i].tag, &attachment[j].stream->metadata, NULL); } else if (tags[i].target.chapteruid) { MatroskaChapter *chapter = matroska->chapters.elem; for (j=0; jchapters.nb_elem; j++) - if (chapter[j].uid == tags[i].target.chapteruid) + if (chapter[j].uid == tags[i].target.chapteruid + && chapter[j].chapter) matroska_convert_tag(s, &tags[i].tag, &chapter[j].chapter->metadata, NULL); } else if (tags[i].target.trackuid) { MatroskaTrack *track = matroska->tracks.elem; for (j=0; jtracks.nb_elem; j++) - if (track[j].uid == tags[i].target.trackuid) + if (track[j].uid == tags[i].target.trackuid && track[j].stream) matroska_convert_tag(s, &tags[i].tag, &track[j].stream->metadata, NULL); } else {