From d633f523e36e3b6d01cc6d57386458d770d618be Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 26 Nov 2020 20:48:42 -0800 Subject: Fix float-approx negative left shift UB Reported by toto. --- celt/mathops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/celt/mathops.h b/celt/mathops.h index 5e86ff0d..fe29dac1 100644 --- a/celt/mathops.h +++ b/celt/mathops.h @@ -137,7 +137,7 @@ static OPUS_INLINE float celt_log2(float x) } in; in.f = x; integer = (in.i>>23)-127; - in.i -= integer<<23; + in.i -= (opus_uint32)integer<<23; frac = in.f - 1.5f; frac = -0.41445418f + frac*(0.95909232f + frac*(-0.33951290f + frac*0.16541097f)); @@ -160,7 +160,7 @@ static OPUS_INLINE float celt_exp2(float x) /* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */ res.f = 0.99992522f + frac * (0.69583354f + frac * (0.22606716f + 0.078024523f*frac)); - res.i = (res.i + (integer<<23)) & 0x7fffffff; + res.i = (res.i + ((opus_uint32)integer<<23)) & 0x7fffffff; return res.f; } -- cgit v1.2.3