diff mbox series

[FFmpeg-devel,5/5] avcodec/tests/dct: Use 64bit in intermediate for error computation

Message ID 20240516231932.6950-5-michael@niedermayer.cc
State Accepted
Commit 161d0aa2a8d18f1f8a01cbc4c1061eadcbe592e5
Headers show
Series [FFmpeg-devel,1/5] avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 16, 2024, 11:19 p.m. UTC
Fixes: CID1500284 Unintentional integer overflow

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/tests/dct.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/tests/dct.c b/libavcodec/tests/dct.c
index 010d0c1ac35..17a08144597 100644
--- a/libavcodec/tests/dct.c
+++ b/libavcodec/tests/dct.c
@@ -226,8 +226,8 @@  static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c
             v = abs(err);
             if (v > err_inf)
                 err_inf = v;
-            err2_matrix[i] += v * v;
-            err2 += v * v;
+            err2_matrix[i] += v * (int64_t)v;
+            err2 += v * (int64_t)v;
             sysErr[i] += block[i] - block1[i];
             blockSumErr += v;
             if (abs(block[i]) > maxout)