[FFmpeg-devel] [PATCH 3/8] avformat/matroskadec: Fix handling gigantic durations

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Thu Sep 5 23:16:04 EEST 2019


matroska_parse_block currently asserts that the duration is not equal to
AV_NOPTS_VALUE, but there is nothing that actually guarantees this. It
is easy to create (spec-compliant) files which run into this assert;
so replace it and instead cap the duration to INT64_MAX, as the duration
field of an AVPacket is an int64_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/matroskadec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 47386b2631..bdbddb58a5 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3565,7 +3565,8 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf
     st = track->stream;
     if (st->discard >= AVDISCARD_ALL)
         return res;
-    av_assert1(block_duration != AV_NOPTS_VALUE);
+    if (block_duration > INT64_MAX)
+        block_duration = INT64_MAX;
 
     block_time = sign_extend(AV_RB16(data), 16);
     data      += 2;
-- 
2.21.0



More information about the ffmpeg-devel mailing list