From 980e8ca4dc0cb88191a453494e17d85ef5051379 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Dec 2013 22:19:51 +0800 Subject: [PATCH] Free the node environment when releasing context. --- renderer/atom_renderer_client.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/renderer/atom_renderer_client.cc b/renderer/atom_renderer_client.cc index f42e31087bc4..cd2074696678 100644 --- a/renderer/atom_renderer_client.cc +++ b/renderer/atom_renderer_client.cc @@ -57,9 +57,17 @@ void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame, atom_bindings_->BindToFrame(frame); } -void AtomRendererClient::WillReleaseScriptContext(WebKit::WebFrame* frame, - v8::Handle, - int world_id) { +void AtomRendererClient::WillReleaseScriptContext( + WebKit::WebFrame* frame, + v8::Handle context, + int world_id) { + node::Environment* env = node::Environment::GetCurrent(context); + if (env == NULL) { + LOG(ERROR) << "Encounter a non-node context when releasing script context"; + return; + } + + env->Dispose(); } } // namespace atom