summaryrefslogtreecommitdiff
path: root/src/node_script.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_script.cc')
-rw-r--r--src/node_script.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/node_script.cc b/src/node_script.cc
index 609b616622..279d26f405 100644
--- a/src/node_script.cc
+++ b/src/node_script.cc
@@ -355,7 +355,14 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
if (output_flag == returnResult) {
result = script->Run();
- if (result.IsEmpty()) return try_catch.ReThrow();
+ if (result.IsEmpty()) {
+ if (context_flag == newContext) {
+ context->DetachGlobal();
+ context->Exit();
+ context.Dispose();
+ }
+ return try_catch.ReThrow();
+ }
} else {
WrappedScript *n_script = ObjectWrap::Unwrap<WrappedScript>(args.Holder());
if (!n_script) {