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-06-02 22:13:36 +0300
commit2937c649f4666d1b0aa0bd69eff6d0d0de8cbcb2 (patch)
tree92fdf512448482f704c428ac5210a6d7ea94c773
parentcc50244f2af763bc425673b1fb69539e8876d3c2 (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 */