diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-09 06:56:53 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-09 07:04:12 +0200 |
commit | 44841528c197435be44f0c3598098e6c52f0df26 (patch) | |
tree | 6d24d5896b75ee0370d5517aefd7377bf927ff67 /libavcodec | |
parent | 9d66aa2c8fa60fe4a570021175ce66316baeb746 (diff) | |
download | ffmpeg-44841528c197435be44f0c3598098e6c52f0df26.tar.gz |
avcodec/mpegaudioenc_template: reorder operations to prevent integer overflow
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mpegaudioenc_template.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/mpegaudioenc_template.c b/libavcodec/mpegaudioenc_template.c index 5ae4269c26..451d140444 100644 --- a/libavcodec/mpegaudioenc_template.c +++ b/libavcodec/mpegaudioenc_template.c @@ -700,9 +700,10 @@ static void encode_frame(MpegAudioContext *s, else q1 = sample >> shift; q1 = (q1 * mult) >> P; - q[m] = ((q1 + (1 << P)) * steps) >> (P + 1); - if (q[m] < 0) - q[m] = 0; + q1 += 1 << P; + if (q1 < 0) + q1 = 0; + q[m] = (unsigned)(q1 * steps) >> (P + 1); } #endif if (q[m] >= steps) |