Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoen Vos <koenvos@users.noreply.github.com>2016-05-31 16:18:21 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-07-08 21:13:58 +0300
commitd9c6c11f2443e11165eecb26d06b1eee19ab6a54 (patch)
treed4650d2f4e8a4e41e5a46dbf16125db58b402491
parenta2d70814c4108ffd998adaef0e6a4f54b7c1714d (diff)
fix potential overflow
-rw-r--r--silk/sum_sqr_shift.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/silk/sum_sqr_shift.c b/silk/sum_sqr_shift.c
index e387391a..43c6b5aa 100644
--- a/silk/sum_sqr_shift.c
+++ b/silk/sum_sqr_shift.c
@@ -70,6 +70,11 @@ void silk_sum_sqr_shift(
/* One sample left to process */
nrg_tmp = silk_SMULBB( x[ i ], x[ i ] );
nrg = (opus_int32)silk_ADD_RSHIFT_uint( nrg, nrg_tmp, shft );
+ if( nrg < 0 ) {
+ /* Scale down */
+ nrg = (opus_int32)silk_RSHIFT_uint( (opus_uint32)nrg, 1 );
+ shft++;
+ }
}
/* Make sure to have at least 10% headroom */