aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-05-21 21:04:42 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2008-05-21 21:04:42 +0000
commit2ea2340e34e8dbd18903a7fca8cc9cc037fd9487 (patch)
tree8c13188f4efec0b4179492d536ccbddd94f9e602 /libavformat
parentc4355f4eaa804bd9b10a2b30cd2dbf445ccc3817 (diff)
downloadffmpeg-2ea2340e34e8dbd18903a7fca8cc9cc037fd9487.tar.gz
check pkt stream index before returning packet, prevent segfault
Originally committed as revision 13224 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/ffm.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavformat/ffm.c b/libavformat/ffm.c
index 872e6f0ba8..bb2ee4bc97 100644
--- a/libavformat/ffm.c
+++ b/libavformat/ffm.c
@@ -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;