aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-05-10 01:26:39 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-05-14 12:20:16 +0200
commitdcc5cdbdbbcce1a5e45aa0362bd78bcdd24dbdb9 (patch)
treec5b3b39d9b6731ea1d19a3e4817433c351a2b892
parentf01e5156df1bf4f141f18c98c2d87046310af883 (diff)
downloadffmpeg-dcc5cdbdbbcce1a5e45aa0362bd78bcdd24dbdb9.tar.gz
avcodec/svq3: Fix multiple runtime error: signed integer overflow: -237341 * 24552 cannot be represented in type 'int'
Fixes: 1429/clusterfuzz-testcase-minimized-5959951610544128 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit ae6fd1790f48c457a8cedb445dcac73f8f7b7698) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/svq3.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index 1dd10a1a04..b10c020258 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -281,16 +281,16 @@ static void svq3_add_idct_c(uint8_t *dst, int16_t *block,
}
for (i = 0; i < 4; i++) {
- const int z0 = 13 * (block[i + 4 * 0] + block[i + 4 * 2]);
- const int z1 = 13 * (block[i + 4 * 0] - block[i + 4 * 2]);
- const int z2 = 7 * block[i + 4 * 1] - 17 * block[i + 4 * 3];
- const int z3 = 17 * block[i + 4 * 1] + 7 * block[i + 4 * 3];
+ const unsigned z0 = 13 * (block[i + 4 * 0] + block[i + 4 * 2]);
+ const unsigned z1 = 13 * (block[i + 4 * 0] - block[i + 4 * 2]);
+ const unsigned z2 = 7 * block[i + 4 * 1] - 17 * block[i + 4 * 3];
+ const unsigned z3 = 17 * block[i + 4 * 1] + 7 * block[i + 4 * 3];
const int rr = (dc + 0x80000);
- dst[i + stride * 0] = av_clip_uint8(dst[i + stride * 0] + ((z0 + z3) * qmul + rr >> 20));
- dst[i + stride * 1] = av_clip_uint8(dst[i + stride * 1] + ((z1 + z2) * qmul + rr >> 20));
- dst[i + stride * 2] = av_clip_uint8(dst[i + stride * 2] + ((z1 - z2) * qmul + rr >> 20));
- dst[i + stride * 3] = av_clip_uint8(dst[i + stride * 3] + ((z0 - z3) * qmul + rr >> 20));
+ dst[i + stride * 0] = av_clip_uint8(dst[i + stride * 0] + ((int)((z0 + z3) * qmul + rr) >> 20));
+ dst[i + stride * 1] = av_clip_uint8(dst[i + stride * 1] + ((int)((z1 + z2) * qmul + rr) >> 20));
+ dst[i + stride * 2] = av_clip_uint8(dst[i + stride * 2] + ((int)((z1 - z2) * qmul + rr) >> 20));
+ dst[i + stride * 3] = av_clip_uint8(dst[i + stride * 3] + ((int)((z0 - z3) * qmul + rr) >> 20));
}
memset(block, 0, 16 * sizeof(int16_t));