#2: Cast rate setter value and u8::MAX to f32 to prevent overflow/padding.

This commit is contained in:
Nolan Darilek 2019-10-16 07:50:38 -05:00
parent 8fc2321050
commit ec99d318d3

View File

@ -35,7 +35,8 @@ impl NativeClass for TTS {
if v > 100 {
v = 100;
}
let v = v / 100 * u8::MAX;
let mut v = v as f32;
v = v * u8::MAX as f32 / 100.;
this.0.set_rate(v as u8).unwrap();
},
usage: PropertyUsage::DEFAULT,