diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 2d60bfb9ca..d2f0152735 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -327,6 +327,7 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end) uint16_t size = avio_rl16(s->pb); const char *name = NULL; char buffer[64] = {0}; + size = FFMIN(size, tag_end - avio_tell(s->pb)); size -= avio_read(s->pb, buffer, FFMIN(size, sizeof(buffer)-1)); switch (tag) {