Browse Source

Fixes the circular reference in vm modules.

Fixes the circular reference problem. Closes GH-822.
v0.7.4-release
Jakub Lekstan 14 years ago
committed by Ryan Dahl
parent
commit
81cbd42cf5
  1. 1
      src/node_script.cc
  2. 12
      test/simple/test-vm-create-context-circular-reference.js

1
src/node_script.cc

@ -221,6 +221,7 @@ Handle<Value> WrappedScript::CreateContext(const Arguments& args) {
for (uint32_t i = 0; i < keys->Length(); i++) { for (uint32_t i = 0; i < keys->Length(); i++) {
Handle<String> key = keys->Get(Integer::New(i))->ToString(); Handle<String> key = keys->Get(Integer::New(i))->ToString();
Handle<Value> value = sandbox->Get(key); Handle<Value> value = sandbox->Get(key);
if(value == sandbox) { value = context; }
context->Set(key, value); context->Set(key, value);
} }
} }

12
test/simple/test-vm-create-context-circular-reference.js

@ -0,0 +1,12 @@
var common = require('../common');
var assert = require('assert');
var vm = require('vm');
var sbx = {};
sbx.window = sbx;
sbx = vm.createContext(sbx);
sbx.test = 123;
assert.equal(sbx.window.window.window.window.window.test, 123);
Loading…
Cancel
Save