mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-11 16:09:32 +00:00
LibJS: Use Array::create() length arg in favor of set_array_like_size()
This way we don't bypass the maximum length check.
This commit is contained in:
@@ -150,8 +150,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map)
|
||||
auto initial_length = length_of_array_like(global_object, *this_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto* new_array = Array::create(global_object);
|
||||
new_array->indexed_properties().set_array_like_size(initial_length);
|
||||
auto* new_array = Array::create(global_object, initial_length);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
for_each_item(vm, global_object, "map", [&](auto index, auto, auto callback_result) {
|
||||
if (vm.exception())
|
||||
return IterationDecision::Break;
|
||||
|
||||
@@ -166,8 +166,9 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::exec)
|
||||
auto& match = result.matches[0];
|
||||
|
||||
// FIXME: Do code point index correction if the Unicode flag is set.
|
||||
auto* array = Array::create(global_object);
|
||||
array->indexed_properties().set_array_like_size(result.n_capture_groups + 1);
|
||||
auto* array = Array::create(global_object, result.n_capture_groups + 1);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
array->define_property(vm.names.index, Value((i32)match.global_offset));
|
||||
array->define_property(vm.names.input, js_string(vm, str));
|
||||
array->indexed_properties().put(array, 0, js_string(vm, match.view.to_string()));
|
||||
|
||||
Reference in New Issue
Block a user