From ec99d318d3d978871f98fa46607f23526693424f Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 16 Oct 2019 07:50:38 -0500 Subject: [PATCH] #2: Cast rate setter value and `u8::MAX` to `f32` to prevent overflow/padding. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index bf70f7a..7c9fd99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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,