From f11277b50df7b84055ce6bb022aae37b24249123 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 13 Nov 2021 14:21:08 +0000 Subject: [PATCH] LibJS: Fix missing handling of "week" largest_unit in balance_duration() It would crash because of VERIFY(largest_unit == "nanosecond"sv) in the final else branch when passing "week", because it's not handled in any of the previous branches. --- Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index 0643c45dd1..034bbfc4d0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -381,7 +381,7 @@ ThrowCompletionOr balance_duration(GlobalObject& global_object result_nanoseconds = fabs(result_nanoseconds); // 10. If largestUnit is "year", "month", "week", "day", or "hour", then - if (largest_unit.is_one_of("year"sv, "month"sv, "day"sv, "hour"sv)) { + if (largest_unit.is_one_of("year"sv, "month"sv, "week"sv, "day"sv, "hour"sv)) { // a. Set microseconds to floor(nanoseconds / 1000). auto nanoseconds_division_result = total_nanoseconds.divided_by(Crypto::UnsignedBigInteger(1000)); // b. Set nanoseconds to nanoseconds modulo 1000.