fix overflow in string.split, close #101 (#102)
Some checks failed
CI / tests (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / clippy (push) Has been cancelled
CI / bootstrap (push) Has been cancelled

This commit is contained in:
qaqland 2024-09-08 05:51:38 +08:00 committed by GitHub
parent e0bb9e2eab
commit 692dc39f55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -155,7 +155,7 @@ pub(crate) fn str_split(mut args: ArgumentResult, visitor: &mut Visitor) -> Sass
.into()); .into());
} }
// note: `1 + limit_int` is required to match dart-sass // 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)) .map(|s| Value::String(s.to_string(), QuoteKind::Quoted))
.collect() .collect()
}; };