check pkt stream index before returning packet, prevent segfault

Originally committed as revision 13224 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Baptiste Coudurier 2008-05-21 21:04:42 +00:00
parent c4355f4eaa
commit 2ea2340e34

View File

@ -610,6 +610,12 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
av_new_packet(pkt, size);
pkt->stream_index = ffm->header[0];
if ((unsigned)pkt->stream_index >= s->nb_streams) {
av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
av_free_packet(pkt);
ffm->read_state = READ_HEADER;
return AVERROR(EAGAIN);
}
pkt->pos = url_ftell(s->pb);
if (ffm->header[1] & FLAG_KEY_FRAME)
pkt->flags |= PKT_FLAG_KEY;