Commit d261a894 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[execution] Reset InvokeParams when calling scripts

We use the InvokeParams to pass host-defined options to Invoke.
The script should never access them directly and thus we should clear
out the argv and argc values.

Bug: chromium:1244145
Change-Id: I915186d624f92581af79ca62bcb1613bc4069640
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3263891Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77738}
parent 1fa34d14
......@@ -57,6 +57,15 @@ struct InvokeParams {
return function->shared().is_script();
}
Handle<FixedArray> GetAndResetHostDefinedOptions() {
DCHECK(IsScript());
DCHECK_EQ(argc, 1);
auto options = Handle<FixedArray>::cast(argv[0]);
argv = nullptr;
argc = 0;
return options;
}
Handle<Object> target;
Handle<Object> receiver;
int argc;
......@@ -330,10 +339,9 @@ V8_WARN_UNUSED_RESULT MaybeHandle<Object> Invoke(Isolate* isolate,
#endif
// Set up a ScriptContext when running scripts that need it.
if (function->shared().needs_script_context()) {
DCHECK_EQ(params.argc, 1);
Handle<Context> context;
Handle<FixedArray> host_defined_options =
Handle<FixedArray>::cast(params.argv[0]);
const_cast<InvokeParams&>(params).GetAndResetHostDefinedOptions();
if (!NewScriptContext(isolate, function, host_defined_options)
.ToHandle(&context)) {
if (params.message_handling == Execution::MessageHandling::kReport) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment