mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibJS: Fix fraction substring in parse_time_zone_offset_string()
We're supposed to get the substring from `fraction`, which is guaranteed to have the required length. `fraction_part` is the user-supplied value and trying to get a substring view from 0-9 might crash.
This commit is contained in:
Notes:
sideshowbarker
2024-07-18 01:26:26 +09:00
@@ -285,7 +285,7 @@ ThrowCompletionOr<double> parse_time_zone_offset_string(GlobalObject& global_obj
|
||||
auto fraction = String::formatted("{}000000000", *fraction_part);
|
||||
// b. Let nanoseconds be the String value equal to the substring of fraction consisting of the code units with indices 0 (inclusive) through 9 (exclusive).
|
||||
// c. Set nanoseconds to ! ToIntegerOrInfinity(nanoseconds).
|
||||
nanoseconds = MUST(Value(js_string(vm, fraction_part->substring_view(0, 9))).to_integer_or_infinity(global_object));
|
||||
nanoseconds = MUST(Value(js_string(vm, fraction.substring_view(0, 9))).to_integer_or_infinity(global_object));
|
||||
}
|
||||
// 11. Else,
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user