aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeelkamal Semwal <neelkamal.semwal@ittiam.com>2021-07-08 09:15:53 +0530
committerRay Essick <essick@google.com>2021-11-05 14:42:13 -0700
commitf6646105b9b8d9b5912f606da818d614b3171f78 (patch)
tree600db2cceed1c6fffd057f37bba63a75f313e843
parent5fb49e35e9c0928fe6e5bda34bcf7864bd301319 (diff)
downloadlibopus-f6646105b9b8d9b5912f606da818d614b3171f78.tar.gz
libOpus: fix integer overflow in silk_resampler_down2_hp
Bug: 190882774 Test: poc in bug description Change-Id: Ib780a7d3e114ed29047c50459c01462c6b244f31
-rw-r--r--src/analysis.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/analysis.c b/src/analysis.c
index 058328f0..8b4f22d0 100644
--- a/src/analysis.c
+++ b/src/analysis.c
@@ -149,7 +149,10 @@ static opus_val32 silk_resampler_down2_hp(
out32_hp = ADD32( out32_hp, X );
S[ 2 ] = ADD32( -in32, X );
- hp_ener += out32_hp*(opus_val64)out32_hp;
+ if(__builtin_add_overflow(hp_ener, out32_hp*(opus_val64)out32_hp, &hp_ener))
+ {
+ hp_ener = UINT64_MAX;
+ }
/* Add, convert back to int16 and store to output */
out[ k ] = HALF32(out32);
}