Commit 2ea2340e authored by Baptiste Coudurier's avatar Baptiste Coudurier

check pkt stream index before returning packet, prevent segfault

Originally committed as revision 13224 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent c4355f4e
...@@ -610,6 +610,12 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -610,6 +610,12 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
av_new_packet(pkt, size); av_new_packet(pkt, size);
pkt->stream_index = ffm->header[0]; 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); pkt->pos = url_ftell(s->pb);
if (ffm->header[1] & FLAG_KEY_FRAME) if (ffm->header[1] & FLAG_KEY_FRAME)
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment