Skip to content

Commit 7c00321

Browse files
committed
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. Fixes #6287
1 parent c38b6d2 commit 7c00321

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

β€Žsrc/node_contextify.ccβ€Ž

Lines changed: 6 additions & 2 deletions
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β€Ž

Lines changed: 1 addition & 1 deletion
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)