diff --git a/libavformat/demux.c b/libavformat/demux.c index cba1f2e4df..d8ab29431e 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -2810,7 +2810,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) av_packet_unref(pkt1); break; } - if (pkt->duration > 0) { + if (pkt->duration > 0 && pkt->duration < INT64_MAX - sti->info->codec_info_duration) { const int fields = sti->codec_desc && (sti->codec_desc->props & AV_CODEC_PROP_FIELDS); if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && st->start_time != AV_NOPTS_VALUE && pkt->pts >= st->start_time && (uint64_t)pkt->pts - st->start_time < INT64_MAX