From 310bf8aaeda88c2c5a7ce4bc16301f4ce1c32c04 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 25 Jan 2024 12:05:09 +0800 Subject: [PATCH] Fix sleep bug. --- CHANGELOG.md | 1 + src/packages/lang_core.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e474117e1..b4586e450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ Fixes to bugs found via fuzzing * Fixed improper parsing of numbers with too many decimal points. * Fixed exponential running time when raising a decimal number to a very large power (> 1 million) -- it now returns an overflow error. * Shared values that contain reference loops no longer cause a stack overflow when printing. +* `sleep` no longer panics on `NaN`. Other bug fixes --------------- diff --git a/src/packages/lang_core.rs b/src/packages/lang_core.rs index 25bea26ca..1efc688cc 100644 --- a/src/packages/lang_core.rs +++ b/src/packages/lang_core.rs @@ -136,7 +136,7 @@ mod core_functions { #[cfg(not(feature = "no_std"))] #[rhai_fn(name = "sleep", volatile)] pub fn sleep_float(seconds: FLOAT) { - if seconds <= 0.0 { + if !seconds.is_normal() || seconds.is_sign_negative() { return; }