Skip to content

Commit 1490a5c

Browse files
committed
[JSC] Fix Win crash in Temporal since/until methods
https://bugs.webkit.org/show_bug.cgi?id=254650 Reviewed by Mark Lam. Without a JSC testbot for Windows, we hadn't noticed that Temporal.{PlainDate, PlainTime}#{since, until} can crash. The crux of the issue seems to be in having a static constexpr std::initializer_list array, but this can just be a static local anyway. * Source/JavaScriptCore/runtime/TemporalObject.cpp: (JSC::extractDifferenceOptions): Canonical link: https://commits.webkit.org/262273@main
1 parent 6ffaec7 commit 1490a5c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Source/JavaScriptCore/runtime/TemporalObject.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ std::optional<TemporalUnit> temporalSmallestUnit(JSGlobalObject* globalObject, J
300300
return unitType;
301301
}
302302

303-
static constexpr std::initializer_list<TemporalUnit> disallowedUnits[] = {
304-
{ },
305-
{ TemporalUnit::Hour, TemporalUnit::Minute, TemporalUnit::Second, TemporalUnit::Millisecond, TemporalUnit::Microsecond, TemporalUnit::Nanosecond },
306-
{ TemporalUnit::Year, TemporalUnit::Month, TemporalUnit::Week, TemporalUnit::Day }
307-
};
308-
309303
// https://tc39.es/proposal-temporal/#sec-temporal-getdifferencesettings
310304
std::tuple<TemporalUnit, TemporalUnit, RoundingMode, double> extractDifferenceOptions(JSGlobalObject* globalObject, JSValue optionsValue, UnitGroup unitGroup, TemporalUnit defaultSmallestUnit, TemporalUnit defaultLargestUnit)
311305
{
306+
static std::initializer_list<TemporalUnit> disallowedUnits[] = {
307+
{ },
308+
{ TemporalUnit::Hour, TemporalUnit::Minute, TemporalUnit::Second, TemporalUnit::Millisecond, TemporalUnit::Microsecond, TemporalUnit::Nanosecond },
309+
{ TemporalUnit::Year, TemporalUnit::Month, TemporalUnit::Week, TemporalUnit::Day }
310+
};
311+
312312
VM& vm = globalObject->vm();
313313
auto scope = DECLARE_THROW_SCOPE(vm);
314314

0 commit comments

Comments
 (0)