X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Flvfdec.c;h=cd64fb9aeef90be8309c1a7960ddf601c0ba6fcb;hb=bc70684e74a185d7b80c8b80bdedda659cb581b8;hp=b8af25609f991e03a1809406d8c0cf628036444d;hpb=6fc762b4fd2c28ef7a0689a1df5ce200e5f5948f;p=ffmpeg diff --git a/libavformat/lvfdec.c b/libavformat/lvfdec.c index b8af25609f9..cd64fb9aeef 100644 --- a/libavformat/lvfdec.c +++ b/libavformat/lvfdec.c @@ -23,7 +23,7 @@ #include "avformat.h" #include "riff.h" -static int lvf_probe(AVProbeData *p) +static int lvf_probe(const AVProbeData *p) { if (AV_RL32(p->buf) != MKTAG('L', 'V', 'F', 'F')) return 0; @@ -106,6 +106,7 @@ static int lvf_read_packet(AVFormatContext *s, AVPacket *pkt) unsigned size, flags, timestamp, id; int64_t pos; int ret, is_video = 0; + int stream_index; pos = avio_tell(s->pb); while (!avio_feof(s->pb)) { @@ -121,12 +122,15 @@ static int lvf_read_packet(AVFormatContext *s, AVPacket *pkt) case MKTAG('0', '1', 'w', 'b'): if (size < 8) return AVERROR_INVALIDDATA; + stream_index = is_video ? 0 : 1; + if (stream_index >= s->nb_streams) + return AVERROR_INVALIDDATA; timestamp = avio_rl32(s->pb); flags = avio_rl32(s->pb); ret = av_get_packet(s->pb, pkt, size - 8); if (flags & (1 << 12)) pkt->flags |= AV_PKT_FLAG_KEY; - pkt->stream_index = is_video ? 0 : 1; + pkt->stream_index = stream_index; pkt->pts = timestamp; pkt->pos = pos; return ret; @@ -141,7 +145,7 @@ static int lvf_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_EOF; } -AVInputFormat ff_lvf_demuxer = { +const AVInputFormat ff_lvf_demuxer = { .name = "lvf", .long_name = NULL_IF_CONFIG_SMALL("LVF"), .read_probe = lvf_probe,