summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Harris <mark.hsj@gmail.com>2020-11-26 20:48:42 -0800
committerMark Harris <mark.hsj@gmail.com>2021-01-23 15:06:54 -0800
commitd633f523e36e3b6d01cc6d57386458d770d618be (patch)
tree7c7082d7635782b790d04c259a623374f56a6d37
parent794392ecd77e6fc6aafa62c3f6002780abcc2c7c (diff)
downloadopus-d633f523e36e3b6d01cc6d57386458d770d618be.tar.gz
Fix float-approx negative left shift UB
Reported by toto.
-rw-r--r--celt/mathops.h4
1 files 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;
}