Skip to content

Commit

Permalink
Bug 1903963 - Part 2: Add missing valid date-time check to AddDate. r…
Browse files Browse the repository at this point in the history
…=spidermonkey-reviewers,dminor

tc39/proposal-temporal#2891

Depends on D214499

Differential Revision: https://phabricator.services.mozilla.com/D214500
  • Loading branch information
anba committed Jun 26, 2024
1 parent eb4a186 commit b8df29a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/src/builtin/temporal/PlainDate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,13 @@ bool js::temporal::AddISODate(JSContext* cx, const PlainDate& date,
auto balanced = BalanceISODate(regulated.year, regulated.month, int32_t(d));
MOZ_ASSERT(IsValidISODate(balanced));

// Directly validate the result is within the valid limits.
if (!ISODateTimeWithinLimits(balanced)) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_TEMPORAL_PLAIN_DATE_INVALID);
return false;
}

*result = balanced;
return true;
}
Expand Down

0 comments on commit b8df29a

Please sign in to comment.