add out of bound stream index checks
authorAurelien Jacobs <aurel@gnuage.org>
Mon, 10 Mar 2008 21:23:06 +0000 (21:23 +0000)
committerAurelien Jacobs <aurel@gnuage.org>
Mon, 10 Mar 2008 21:23:06 +0000 (21:23 +0000)
fix issue379

Originally committed as revision 12417 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/matroskadec.c

index 8040388..a4274f3 100644 (file)
@@ -2356,7 +2356,7 @@ matroska_read_header (AVFormatContext    *s,
             MatroskaDemuxIndex *idx = &matroska->index[i];
             track = matroska_find_track_by_num(matroska, idx->track);
             stream = matroska->tracks[track]->stream_index;
-            if (stream >= 0)
+            if (stream >= 0 && stream < matroska->ctx->nb_streams)
                 av_add_index_entry(matroska->ctx->streams[stream],
                                    idx->pos, idx->time/matroska->time_scale,
                                    0, 0, AVINDEX_KEYFRAME);
@@ -2400,7 +2400,7 @@ matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size,
         return res;
     }
     stream_index = matroska->tracks[track]->stream_index;
-    if (stream_index < 0) {
+    if (stream_index < 0 || stream_index >= matroska->ctx->nb_streams) {
         av_free(origdata);
         return res;
     }