check stream index validity in av_program_add_stream_index
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>
Mon, 19 Oct 2009 18:55:27 +0000 (18:55 +0000)
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>
Mon, 19 Oct 2009 18:55:27 +0000 (18:55 +0000)
Originally committed as revision 20319 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/utils.c

index 58b3584c1d1ef955825a4a4ce2b0318c0702ac77..4202fc26a23827e0c7d241141b2a38507f728707 100644 (file)
@@ -2833,6 +2833,11 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int i
     AVProgram *program=NULL;
     void *tmp;
 
+    if (idx >= ac->nb_streams) {
+        av_log(ac, AV_LOG_ERROR, "stream index %d is not valid\n", idx);
+        return;
+    }
+
     for(i=0; i<ac->nb_programs; i++){
         if(ac->programs[i]->id != progid)
             continue;