diff mbox

[FFmpeg-devel,1/2] avcodec/h264_direct: Fix runtime error: signed integer overflow: 2147483647 - -14133 cannot be represented in type 'int'

Message ID 20170309030735.26598-1-michael@niedermayer.cc
State Superseded
Headers show

Commit Message

Michael Niedermayer March 9, 2017, 3:07 a.m. UTC
Fixes: 755/clusterfuzz-testcase-5369072516595712

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/h264_direct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

wm4 March 9, 2017, 7:01 a.m. UTC | #1
On Thu,  9 Mar 2017 04:07:34 +0100
Michael Niedermayer <michael@niedermayer.cc> wrote:

> Fixes: 755/clusterfuzz-testcase-5369072516595712
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/h264_direct.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
> index cbb84665b3..798cb10c2b 100644
> --- a/libavcodec/h264_direct.c
> +++ b/libavcodec/h264_direct.c
> @@ -39,7 +39,7 @@ static int get_scale_factor(H264SliceContext *sl,
>                              int poc, int poc1, int i)
>  {
>      int poc0 = sl->ref_list[0][i].poc;
> -    int td = av_clip_int8(poc1 - poc0);
> +    int td = av_clip_int8(poc1 - (SUINT)poc0);
>      if (td == 0 || sl->ref_list[0][i].parent->long_ref) {
>          return 256;
>      } else {

Same comment like for the previous 2/6 patch here.
diff mbox

Patch

diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index cbb84665b3..798cb10c2b 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -39,7 +39,7 @@  static int get_scale_factor(H264SliceContext *sl,
                             int poc, int poc1, int i)
 {
     int poc0 = sl->ref_list[0][i].poc;
-    int td = av_clip_int8(poc1 - poc0);
+    int td = av_clip_int8(poc1 - (SUINT)poc0);
     if (td == 0 || sl->ref_list[0][i].parent->long_ref) {
         return 256;
     } else {