Skip to content

Commit

Permalink
src: fix delete operator on vm context
Browse files Browse the repository at this point in the history
In the implementation of the vm module,
if a property is successfully deleted
on the sandbox, we also need to delete it
on the global_proxy object. Therefore, we
must not call args.GetReturnValue().Set().

We only intercept, i.e., call
args.GetReturnValue().Set(), in the
DeleterCallback, if Delete() failed, e.g. because
the property was read only.

PR-URL: #11266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
fhinkel authored and italoacasas committed Feb 14, 2017
1 parent e530b5a commit 308df11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,12 @@ class ContextifyContext {

Maybe<bool> success = ctx->sandbox()->Delete(ctx->context(), property);

if (success.IsJust())
args.GetReturnValue().Set(success.FromJust());
if (success.FromMaybe(false))
return;

// Delete failed on the sandbox, intercept and do not delete on
// the global object.
args.GetReturnValue().Set(false);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ const res = vm.runInContext(`
Object.getOwnPropertyDescriptor(this, 'x');
`, context);

assert.strictEqual(res.value, undefined);
assert.strictEqual(res, undefined);

0 comments on commit 308df11

Please sign in to comment.