diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-01-16 00:54:48 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-16 11:07:02 +0100 |
commit | 4848f587cd6abe5b5008e7a232fa8d0dae9630c2 (patch) | |
tree | 8348c4a44c7c1673859576f0c2a52eb7a5af437e /Userland | |
parent | 9be0a0fd28a295200f6e5377c37b8f454aab79db (diff) | |
download | serenity-4848f587cd6abe5b5008e7a232fa8d0dae9630c2.zip |
LibJS: Protect DayWithinYear against non-finite times
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Date.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Date.cpp b/Userland/Libraries/LibJS/Runtime/Date.cpp index 484191ff5d..fe1962676e 100644 --- a/Userland/Libraries/LibJS/Runtime/Date.cpp +++ b/Userland/Libraries/LibJS/Runtime/Date.cpp @@ -63,6 +63,9 @@ String Date::iso_date_string() const // DayWithinYear(t), https://tc39.es/ecma262/#eqn-DayWithinYear u16 day_within_year(double t) { + if (!Value(t).is_finite_number()) + return 0; + // Day(t) - DayFromYear(YearFromTime(t)) return static_cast<u16>(day(t) - day_from_year(year_from_time(t))); } |