Skip to content

Commit 308df11

Browse files
fhinkelitaloacasas
authored andcommitted
src: fix delete operator on vm context
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent e530b5a commit 308df11

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/node_contextify.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,12 @@ class ContextifyContext {
456456

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

459-
if (success.IsJust())
460-
args.GetReturnValue().Set(success.FromJust());
459+
if (success.FromMaybe(false))
460+
return;
461+
462+
// Delete failed on the sandbox, intercept and do not delete on
463+
// the global object.
464+
args.GetReturnValue().Set(false);
461465
}
462466

463467

test/known_issues/test-vm-deleting-property.js renamed to test/parallel/test-vm-deleting-property.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ const res = vm.runInContext(`
1212
Object.getOwnPropertyDescriptor(this, 'x');
1313
`, context);
1414

15-
assert.strictEqual(res.value, undefined);
15+
assert.strictEqual(res, undefined);

0 commit comments

Comments
 (0)