From 9628452550d4f19a86820c9aa94a42beda9e8b52 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 19 Nov 2021 18:07:23 +0000 Subject: [PATCH] LibJS: Fix fallback of hour, minute, second in parse_iso_date_time() It's not the `to_uint()` call that would fail, if we have a value for these productions they will always be valid numbers. We do need to provide a fallback for when that's not the case and any of them is undefined, i.e. an empty Optional. --- .../Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 26185f5120..500f09ee80 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -1105,13 +1105,13 @@ ThrowCompletionOr parse_iso_date_time(GlobalObject& global_object, } // 10. Set hour to ! ToIntegerOrInfinity(hour). - u8 hour = hour_part->to_uint().value_or(0); + u8 hour = *hour_part.value_or("0"sv).to_uint(); // 11. Set minute to ! ToIntegerOrInfinity(minute). - u8 minute = minute_part->to_uint().value_or(0); + u8 minute = *minute_part.value_or("0"sv).to_uint(); // 12. Set second to ! ToIntegerOrInfinity(second). - u8 second = second_part->to_uint().value_or(0); + u8 second = *second_part.value_or("0"sv).to_uint(); // 13. If second is 60, then if (second == 60) {