diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-11-20 00:13:34 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2009-11-20 00:13:34 +0000 |
commit | cb893cf38662d9c532de41e0fd03d0fdd992a557 (patch) | |
tree | 24e9ebe0b96e385905d25f1d556de7aecd542938 | |
parent | a4fcd9966b3423c47e1e43598173aa6926a6acc4 (diff) | |
download | ffmpeg-cb893cf38662d9c532de41e0fd03d0fdd992a557.tar.gz |
avoid integer overflow in dnxhd encoder, fixes #1557
Originally committed as revision 20557 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/dnxhdenc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index db0f09dd78..a52fe8684e 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -574,9 +574,11 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx) last_higher = FFMAX(lambda, last_higher); if (last_lower != INT_MAX) lambda = (lambda+last_lower)>>1; + else if ((int64_t)lambda + up_step > INT_MAX) + return -1; else lambda += up_step; - up_step *= 5; + up_step = FFMIN((int64_t)up_step*5, INT_MAX); down_step = 1<<LAMBDA_FRAC_BITS; } } |