Skip to content

Commit

Permalink
Fixes the circular reference in vm modules.
Browse files Browse the repository at this point in the history
Fixes the circular reference problem. Closes nodejsGH-822.
  • Loading branch information
kuebk authored and ry committed Apr 12, 2011
1 parent 9b3b37e commit 81cbd42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/node_script.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Handle<Value> WrappedScript::CreateContext(const Arguments& args) {
for (uint32_t i = 0; i < keys->Length(); i++) {
Handle<String> key = keys->Get(Integer::New(i))->ToString();
Handle<Value> value = sandbox->Get(key);
if(value == sandbox) { value = context; }
context->Set(key, value);
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/simple/test-vm-create-context-circular-reference.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 81cbd42

Please sign in to comment.