summaryrefslogtreecommitdiff
path: root/libavcodec/flacdsp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-02-19 14:34:55 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-02-19 15:58:30 +0100
commit3e1028c625e11d9d19376f5c88267de1cee8fa70 (patch)
tree687d71ab3c35a2771450ced8c03724dc39c91d5c /libavcodec/flacdsp.c
parente8d4eacc07c61ae24f48451073a2620d8d257d33 (diff)
avcodec/flac: Fix several integer overflows
Fixes: 686513-media Found-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/flacdsp.c')
-rw-r--r--libavcodec/flacdsp.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index 52c3e32ed0..560091f73a 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -43,14 +43,6 @@
#define PLANAR 1
#include "flacdsp_template.c"
-// For debuging we use signed operations so overflows can be detected (by ubsan)
-// For production we use unsigned so there are no undefined operations
-#ifdef CHECKED
-#define SUINT int
-#else
-#define SUINT unsigned
-#endif
-
static void flac_lpc_16_c(int32_t *decoded, const int coeffs[32],
int pred_order, int qlevel, int len)
{
@@ -67,9 +59,9 @@ static void flac_lpc_16_c(int32_t *decoded, const int coeffs[32],
c = coeffs[j];
}
s0 += c*d;
- d = decoded[j] += s0 >> qlevel;
+ d = decoded[j] += (SUINT)(s0 >> qlevel);
s1 += c*d;
- decoded[j + 1] += s1 >> qlevel;
+ decoded[j + 1] += (SUINT)(s1 >> qlevel);
}
if (i < len) {
int sum = 0;