fix: crash in utilityProcess when generating code from strings (#38014)
This commit is contained in:
parent
f12e12b341
commit
0240f6664e
14 changed files with 72 additions and 48 deletions
|
@ -171,7 +171,7 @@ bool AllowWasmCodeGenerationCallback(v8::Local<v8::Context> context,
|
|||
// If we're running with contextIsolation enabled in the renderer process,
|
||||
// fall back to Blink's logic.
|
||||
if (node::Environment::GetCurrent(context) == nullptr) {
|
||||
if (gin_helper::Locker::IsBrowserProcess())
|
||||
if (!electron::IsRendererProcess())
|
||||
return false;
|
||||
return blink::V8Initializer::WasmCodeGenerationCheckCallbackInMainThread(
|
||||
context, source);
|
||||
|
@ -188,7 +188,7 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings(
|
|||
// No node environment means we're in the renderer process, either in a
|
||||
// sandboxed renderer or in an unsandboxed renderer with context isolation
|
||||
// enabled.
|
||||
if (gin_helper::Locker::IsBrowserProcess()) {
|
||||
if (!electron::IsRendererProcess()) {
|
||||
NOTREACHED();
|
||||
return {false, {}};
|
||||
}
|
||||
|
@ -197,21 +197,20 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings(
|
|||
}
|
||||
|
||||
// If we get here then we have a node environment, so either a) we're in the
|
||||
// main process, or b) we're in the renderer process in a context that has
|
||||
// both node and blink, i.e. contextIsolation disabled.
|
||||
|
||||
// If we're in the main process, delegate to node.
|
||||
if (gin_helper::Locker::IsBrowserProcess()) {
|
||||
return node::ModifyCodeGenerationFromStrings(context, source, is_code_like);
|
||||
}
|
||||
// non-rendrer process, or b) we're in the renderer process in a context that
|
||||
// has both node and blink, i.e. contextIsolation disabled.
|
||||
|
||||
// If we're in the renderer with contextIsolation disabled, ask blink first
|
||||
// (for CSP), and iff that allows codegen, delegate to node.
|
||||
v8::ModifyCodeGenerationFromStringsResult result =
|
||||
blink::V8Initializer::CodeGenerationCheckCallbackInMainThread(
|
||||
context, source, is_code_like);
|
||||
if (!result.codegen_allowed)
|
||||
return result;
|
||||
if (electron::IsRendererProcess()) {
|
||||
v8::ModifyCodeGenerationFromStringsResult result =
|
||||
blink::V8Initializer::CodeGenerationCheckCallbackInMainThread(
|
||||
context, source, is_code_like);
|
||||
if (!result.codegen_allowed)
|
||||
return result;
|
||||
}
|
||||
|
||||
// If we're in the main process or utility process, delegate to node.
|
||||
return node::ModifyCodeGenerationFromStrings(context, source, is_code_like);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue