From e6108740c0361946cf386950524e1c879f57e72e Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 3 Jul 2019 15:42:06 -0700 Subject: [PATCH] fix: handle no env in externsion world set up (#19101) Previously when GetEnvironment returned null this extension setup crashed. --- shell/renderer/atom_renderer_client.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/shell/renderer/atom_renderer_client.cc b/shell/renderer/atom_renderer_client.cc index ce59027d3ed1..f8b0c0c02ee2 100644 --- a/shell/renderer/atom_renderer_client.cc +++ b/shell/renderer/atom_renderer_client.cc @@ -202,8 +202,11 @@ void AtomRendererClient::SetupMainWorldOverrides( node::FIXED_ONE_BYTE_STRING(isolate, "nodeProcess"), node::FIXED_ONE_BYTE_STRING(isolate, "isolatedWorld")}; + auto* env = GetEnvironment(render_frame); + DCHECK(env); + std::vector> isolated_bundle_args = { - GetEnvironment(render_frame)->process_object(), + env->process_object(), GetContext(render_frame->GetWebFrame(), isolate)->Global()}; node::per_process::native_module_loader.CompileAndCall( @@ -222,8 +225,12 @@ void AtomRendererClient::SetupExtensionWorldOverrides( node::FIXED_ONE_BYTE_STRING(isolate, "isolatedWorld"), node::FIXED_ONE_BYTE_STRING(isolate, "worldId")}; + auto* env = GetEnvironment(render_frame); + if (!env) + return; + std::vector> isolated_bundle_args = { - GetEnvironment(render_frame)->process_object(), + env->process_object(), GetContext(render_frame->GetWebFrame(), isolate)->Global(), v8::Integer::New(isolate, world_id)};