Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2f88de1

Browse filesBrowse files
AnnaMagItalo A. Casas
authored andcommitted
vm: use SetterCallback to set func declarations
Currently, when in strict mode, function declarations are copied on the sandbox by CopyProperties(), which is not necessary and will break when CP is removed. This change maintains current behavior, letting GlobalPropertySetterCallback copy functions on the sandbox instead of using CP to do the task. PR-URL: #12051 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent ffbcfdf commit 2f88de1
Copy full SHA for 2f88de1

File tree

Expand file treeCollapse file tree

1 file changed

+11
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-1
lines changed
Open diff view settings
Collapse file

‎src/node_contextify.cc‎

Copy file name to clipboardExpand all lines: src/node_contextify.cc
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,17 @@ class ContextifyContext {
411411
// false for vmResult.x = 5 where vmResult = vm.runInContext();
412412
bool is_contextual_store = ctx->global_proxy() != args.This();
413413

414-
if (!is_declared && args.ShouldThrowOnError() && is_contextual_store)
414+
// Indicator to not return before setting (undeclared) function declarations
415+
// on the sandbox in strict mode, i.e. args.ShouldThrowOnError() = true.
416+
// True for 'function f() {}', 'this.f = function() {}',
417+
// 'var f = function()'.
418+
// In effect only for 'function f() {}' because
419+
// var f = function(), is_declared = true
420+
// this.f = function() {}, is_contextual_store = false.
421+
bool is_function = value->IsFunction();
422+
423+
if (!is_declared && args.ShouldThrowOnError() && is_contextual_store &&
424+
!is_function)
415425
return;
416426

417427
ctx->sandbox()->Set(property, value);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.