From a3dd6c635fa3fb32d362661164308d64f9f2246d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 20 Jun 2016 16:51:42 +0900 Subject: [PATCH] Avoid calling Environment::GetCurrent for unjected contexts It seems to cause crashes when it is called for contexts that do not have node integrations. --- atom/renderer/atom_renderer_client.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 99b00227c3b1..63a9a3eb263d 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -282,6 +282,11 @@ void AtomRendererClient::DidCreateScriptContext( void AtomRendererClient::WillReleaseScriptContext( v8::Handle context, content::RenderFrame* render_frame) { + // Only allow node integration for the main frame, unless it is a devtools + // extension page. + if (!render_frame->IsMainFrame() && !IsDevToolsExtension(render_frame)) + return; + node::Environment* env = node::Environment::GetCurrent(context); if (env) mate::EmitEvent(env->isolate(), env->process_object(), "exit");