From 1cc375d34ad18686aa17abdf78458b1940a28bc2 Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Tue, 20 Feb 2024 10:08:13 +0100 Subject: [PATCH] Playtime: Fix panic when converting BPM values --- playtime-api/src/persistence/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/playtime-api/src/persistence/mod.rs b/playtime-api/src/persistence/mod.rs index bfcfe1e0b..34245b97b 100644 --- a/playtime-api/src/persistence/mod.rs +++ b/playtime-api/src/persistence/mod.rs @@ -1483,14 +1483,14 @@ pub struct Bpm(f64); impl Bpm { /// # Safety /// - /// If you pass a value <= 0.0, you get an invalid Bpm value. + /// If you pass a value < 1.0 or > 960.0, you get an invalid Bpm value. pub const unsafe fn new_unchecked(value: f64) -> Self { Self(value) } pub fn new(value: f64) -> PlaytimeApiResult { - if value <= 0.0 { - return Err("BPM value must be > 0.0".into()); + if value < 1.0 || value > 960.0 { + return Err("BPM value must be >= 1.0 and <= 960.0".into()); } Ok(Self(value)) }