mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibJS: Make the options arg of InterpretTemporalDateTimeFields nullable
This fixes "reference binding to null pointer" UBSan warnings.
This commit is contained in:
parent
6eb06384b3
commit
1dce1994eb
Notes:
sideshowbarker
2024-07-16 22:54:10 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/1dce1994eb Pull-request: https://github.com/SerenityOS/serenity/pull/19709
6 changed files with 9 additions and 9 deletions
|
@ -605,7 +605,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
|
|||
MUST(date_options->create_data_property_or_throw(vm.names.overflow, MUST_OR_THROW_OOM(PrimitiveString::create(vm, "constrain"sv))));
|
||||
|
||||
// h. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, dateOptions).
|
||||
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, *date_options));
|
||||
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, date_options));
|
||||
|
||||
// i. Let offsetString be ? Get(value, "offset").
|
||||
offset_string = TRY(value_object.get(vm.names.offset));
|
||||
|
|
|
@ -75,16 +75,16 @@ bool iso_date_time_within_limits(i32 year, u8 month, u8 day, u8 hour, u8 minute,
|
|||
}
|
||||
|
||||
// 5.5.2 InterpretTemporalDateTimeFields ( calendar, fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-interprettemporaldatetimefields
|
||||
ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(VM& vm, Object& calendar, Object& fields, Object const& options)
|
||||
ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(VM& vm, Object& calendar, Object& fields, Object const* options)
|
||||
{
|
||||
// 1. Let timeResult be ? ToTemporalTimeRecord(fields).
|
||||
auto unregulated_time_result = TRY(to_temporal_time_record(vm, fields));
|
||||
|
||||
// 2. Let overflow be ? ToTemporalOverflow(options).
|
||||
auto overflow = TRY(to_temporal_overflow(vm, &options));
|
||||
auto overflow = TRY(to_temporal_overflow(vm, options));
|
||||
|
||||
// 3. Let temporalDate be ? CalendarDateFromFields(calendar, fields, options).
|
||||
auto* temporal_date = TRY(calendar_date_from_fields(vm, calendar, fields, &options));
|
||||
auto* temporal_date = TRY(calendar_date_from_fields(vm, calendar, fields, options));
|
||||
|
||||
// 4. Let timeResult be ? RegulateTime(timeResult.[[Hour]], timeResult.[[Minute]], timeResult.[[Second]], timeResult.[[Millisecond]], timeResult.[[Microsecond]], timeResult.[[Nanosecond]], overflow).
|
||||
auto time_result = TRY(regulate_time(vm, *unregulated_time_result.hour, *unregulated_time_result.minute, *unregulated_time_result.second, *unregulated_time_result.millisecond, *unregulated_time_result.microsecond, *unregulated_time_result.nanosecond, overflow));
|
||||
|
@ -157,7 +157,7 @@ ThrowCompletionOr<PlainDateTime*> to_temporal_date_time(VM& vm, Value item, Obje
|
|||
auto* fields = TRY(prepare_temporal_fields(vm, item_object, field_names, Vector<StringView> {}));
|
||||
|
||||
// g. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
|
||||
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, *options));
|
||||
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, options));
|
||||
}
|
||||
// 4. Else,
|
||||
else {
|
||||
|
|
|
@ -65,7 +65,7 @@ struct TemporalPlainDateTime {
|
|||
};
|
||||
|
||||
bool iso_date_time_within_limits(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond);
|
||||
ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(VM&, Object& calendar, Object& fields, Object const& options);
|
||||
ThrowCompletionOr<ISODateTime> interpret_temporal_date_time_fields(VM&, Object& calendar, Object& fields, Object const* options);
|
||||
ThrowCompletionOr<PlainDateTime*> to_temporal_date_time(VM&, Value item, Object const* options = nullptr);
|
||||
ISODateTime balance_iso_date_time(i32 year, u8 month, u8 day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, i64 nanosecond);
|
||||
ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(VM&, i32 iso_year, u8 iso_month, u8 iso_day, u8 hour, u8 minute, u8 second, u16 millisecond, u16 microsecond, u16 nanosecond, Object& calendar, FunctionObject const* new_target = nullptr);
|
||||
|
|
|
@ -410,7 +410,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with)
|
|||
fields = TRY(prepare_temporal_fields(vm, *fields, field_names, Vector<StringView> {}));
|
||||
|
||||
// 12. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
|
||||
auto result = TRY(interpret_temporal_date_time_fields(vm, calendar, *fields, *options));
|
||||
auto result = TRY(interpret_temporal_date_time_fields(vm, calendar, *fields, options));
|
||||
|
||||
// 13. Assert: IsValidISODate(result.[[Year]], result.[[Month]], result.[[Day]]) is true.
|
||||
VERIFY(is_valid_iso_date(result.year, result.month, result.day));
|
||||
|
|
|
@ -180,7 +180,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item
|
|||
}
|
||||
|
||||
// l. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, options).
|
||||
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, *options));
|
||||
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, options));
|
||||
}
|
||||
// 6. Else,
|
||||
else {
|
||||
|
|
|
@ -806,7 +806,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
|||
auto offset_string = TRY(offset_string_value.as_string().utf8_string());
|
||||
|
||||
// 19. Let dateTimeResult be ? InterpretTemporalDateTimeFields(calendar, fields, options).
|
||||
auto date_time_result = TRY(interpret_temporal_date_time_fields(vm, calendar, *fields, *options));
|
||||
auto date_time_result = TRY(interpret_temporal_date_time_fields(vm, calendar, *fields, options));
|
||||
|
||||
// 20. If IsTimeZoneOffsetString(offsetString) is false, throw a RangeError exception.
|
||||
if (!is_time_zone_offset_string(offset_string))
|
||||
|
|
Loading…
Reference in a new issue