ref: bb564fab954511def5eff2846cc4b2f00bf04e13
parent: 1c370855aa0e7fe3f583d74a2ffd48ca1432a479
author: Jean-Marc Valin <jeanmarcv@google.com>
date: Fri Mar 28 15:19:05 EDT 2025
UBSan fixes for opus_demo
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -929,7 +929,7 @@
for(i=0;i<frame_size*channels;i++)
{
float_bits s;
- s.i=fbytes[4*i+3]<<24|fbytes[4*i+2]<<16|fbytes[4*i+1]<<8|fbytes[4*i];
+ s.i=(opus_uint32)fbytes[4*i+3]<<24|fbytes[4*i+2]<<16|fbytes[4*i+1]<<8|fbytes[4*i];
in[i]=(int)floor(.5 + s.f*8388608);
}
}
@@ -1133,7 +1133,7 @@
/* count bits */
bits += len*8;
bits_max = ( len*8 > bits_max ) ? len*8 : bits_max;
- bits2 += len*len*64;
+ bits2 += len*(double)len*64;
if (!decode_only)
{
nrg = 0.0;
--
⑨