From 692dc39f55a90a362a0086cffcb78d1bd44922b9 Mon Sep 17 00:00:00 2001 From: qaqland Date: Sun, 8 Sep 2024 05:51:38 +0800 Subject: [PATCH] fix overflow in string.split, close #101 (#102) --- crates/compiler/src/builtin/functions/string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compiler/src/builtin/functions/string.rs b/crates/compiler/src/builtin/functions/string.rs index d91ccc2..72ecad7 100644 --- a/crates/compiler/src/builtin/functions/string.rs +++ b/crates/compiler/src/builtin/functions/string.rs @@ -155,7 +155,7 @@ pub(crate) fn str_split(mut args: ArgumentResult, visitor: &mut Visitor) -> Sass .into()); } // note: `1 + limit_int` is required to match dart-sass - s1.splitn(1 + limit_int as usize, &separator) + s1.splitn(limit_int.saturating_add(1) as usize, &separator) .map(|s| Value::String(s.to_string(), QuoteKind::Quoted)) .collect() };