diff options
author | Chris Cunningham <chcunningham@chromium.org> | 2016-07-21 12:01:45 -0700 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-07-23 10:32:28 +0200 |
commit | d59820f6fec3fd112436fb7712e4f9d6d768b664 (patch) | |
tree | 5fd14a2feeb469a550e4530bfc0390fb135d12e8 /libavformat/matroskadec.c | |
parent | 0a088dea3d3335dee885c6486424337649ca2dba (diff) | |
download | ffmpeg-d59820f6fec3fd112436fb7712e4f9d6d768b664.tar.gz |
libavformat/matroskadec: fix unsigned overflow to improve seeking
When seeking a file where codec delay is greater than 0, the timecode
can become negative after offsetting by the codec delay. Failing to cast
to a signed int64 will cause the check against skip_to_timecode to evaluate
true for these negative values. This breaks the "skip_to" seek mechanism.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/matroskadec.c')
-rw-r--r-- | libavformat/matroskadec.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index f3d701fe4d..60b1b345d2 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3150,7 +3150,10 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { - if (timecode < matroska->skip_to_timecode) + // Compare signed timecodes. Timecode may be negative due to codec delay + // offset. We don't support timestamps greater than int64_t anyway - see + // AVPacket's pts. + if ((int64_t)timecode < (int64_t)(matroska->skip_to_timecode)) return res; if (is_keyframe) matroska->skip_to_keyframe = 0; |