diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-03-16 05:02:50 +0300 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-03-20 03:33:08 +0300 |
commit | a84d610b372c63e8a48a9ed7c038a2954097512c (patch) | |
tree | 55b25f954dd2b764abc474ae3efb2c7f2db11364 /libavcodec/h264_direct.c | |
parent | 5d996b56499f00f80b02a41bab3d6b7349e36e9d (diff) |
avcodec/h264_direct: Fix runtime error: signed integer overflow: -9 - 2147483647 cannot be represented in type 'int'
Fixes: 864/clusterfuzz-testcase-4774385942528000
See: [FFmpeg-devel] [PATCH 1/2] avcodec/h264_direct: Fix runtime error: signed integer overflow: 2147483647 - -14133 cannot be represented in type 'int'
See: [FFmpeg-devel] [PATCH 2/2] avcodec/h264_direct: Fix runtime error: signed integer overflow: -9 - 2147483647 cannot be represented in type 'int'
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/h264_direct.c')
-rw-r--r-- | libavcodec/h264_direct.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c index 66e54479d1..4e7202b986 100644 --- a/libavcodec/h264_direct.c +++ b/libavcodec/h264_direct.c @@ -48,8 +48,13 @@ static int get_scale_factor(H264SliceContext *sl, if (td == 0 || sl->ref_list[0][i].parent->long_ref) { return 256; } else { - int tb = av_clip_int8(poc - poc0); + int64_t pocdiff0 = poc - (int64_t)poc0; + int tb = av_clip_int8(pocdiff0); int tx = (16384 + (FFABS(td) >> 1)) / td; + + if (pocdiff0 != (int)pocdiff0) + av_log(sl->h264->avctx, AV_LOG_DEBUG, "pocdiff0 overflow\n"); + return av_clip_intp2((tb * tx + 32) >> 6, 10); } } |