1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:07:35 +00:00

LibJS: Create the RegExpExec result's "input" field last

We move the input string into this field to avoid a string copy, so we
must do this step last to avoid using any views into it (note that
match.view here is a view into this string).
This commit is contained in:
Timothy Flynn 2021-11-07 18:49:04 -05:00 committed by Andreas Kling
parent 79fa9765ca
commit 2530b6adf0
2 changed files with 8 additions and 1 deletions

View file

@ -241,8 +241,8 @@ static ThrowCompletionOr<Value> regexp_builtin_exec(GlobalObject& global_object,
}
MUST(array->create_data_property_or_throw(vm.names.index, Value(match_index)));
MUST(array->create_data_property_or_throw(vm.names.input, js_string(vm, move(string))));
MUST(array->create_data_property_or_throw(0, js_string(vm, match.view.u16_view())));
MUST(array->create_data_property_or_throw(vm.names.input, js_string(vm, move(string))));
return array;
}