diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h index 2f13e1a01d..48c25ca24c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h @@ -11,9 +11,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -54,16 +56,16 @@ struct PatternPartition { }; struct PatternPartitionWithSource : public PatternPartition { - static Vector create_from_parent_list(Vector partitions) + static ThrowCompletionOr> create_from_parent_list(VM& vm, Vector partitions) { Vector result; - result.ensure_capacity(partitions.size()); + TRY_OR_THROW_OOM(vm, result.try_ensure_capacity(partitions.size())); for (auto& partition : partitions) { PatternPartitionWithSource partition_with_source {}; partition_with_source.type = partition.type; partition_with_source.value = move(partition.value); - result.append(move(partition_with_source)); + result.unchecked_append(move(partition_with_source)); } return result; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp index 9dc9247026..71677f575a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp @@ -1079,7 +1079,7 @@ ThrowCompletionOr> partition_date_time_range_ // c. Let result be ? FormatDateTimePattern(dateTimeFormat, patternParts, x, undefined). auto raw_result = TRY(format_date_time_pattern(vm, date_time_format, move(pattern_parts), start, nullptr)); - auto result = PatternPartitionWithSource::create_from_parent_list(move(raw_result)); + auto result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_result))); // d. For each Record { [[Type]], [[Value]] } r in result, do for (auto& part : result) { @@ -1136,7 +1136,7 @@ ThrowCompletionOr> partition_date_time_range_ // f. Let partResult be ? FormatDateTimePattern(dateTimeFormat, patternParts, z, rangePattern). auto raw_part_result = TRY(format_date_time_pattern(vm, date_time_format, move(pattern_parts), time, &range_pattern.value())); - auto part_result = PatternPartitionWithSource::create_from_parent_list(move(raw_part_result)); + auto part_result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_part_result))); // g. For each Record { [[Type]], [[Value]] } r in partResult, do for (auto& part : part_result) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp index 07e826d538..1ba865baec 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp @@ -1801,11 +1801,11 @@ ThrowCompletionOr> partition_number_range_pat // 3. Let xResult be ? PartitionNumberPattern(numberFormat, x). auto raw_start_result = TRY(partition_number_pattern(vm, number_format, move(start))); - auto start_result = PatternPartitionWithSource::create_from_parent_list(move(raw_start_result)); + auto start_result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_start_result))); // 4. Let yResult be ? PartitionNumberPattern(numberFormat, y). auto raw_end_result = TRY(partition_number_pattern(vm, number_format, move(end))); - auto end_result = PatternPartitionWithSource::create_from_parent_list(move(raw_end_result)); + auto end_result = MUST_OR_THROW_OOM(PatternPartitionWithSource::create_from_parent_list(vm, move(raw_end_result))); // 5. If xResult is equal to yResult, then if (start_result == end_result) {