Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[acl] Hoisted global variables in with-clause always need read access #351

Closed
t2ym opened this issue Mar 8, 2020 · 0 comments
Closed

[acl] Hoisted global variables in with-clause always need read access #351

t2ym opened this issue Mar 8, 2020 · 0 comments

Comments

@t2ym
Copy link
Owner

t2ym commented Mar 8, 2020

[acl] Hoisted global variables in with-clause always need read access

Root Cause

  • Unused read access is attached in the hoisted var declarations

Reproducible Code

  • Original
with ({}) {
  var v = 1;
}
  • Hooked (Pseudo)
$hook$.global('v', 'var)[_c_[0]]; // unnecessary read access to the variable with property access
with (__with__) {
  __hook__('w=', __with__, ['v', 1, (p) => v = p, v], _c_[0], false); // write access
}

Fix

  • Omit unnecessary property access
$hook$.global('v', 'var'); // equivalent to Object.defineProperty(window, 'v', { value: undefined })
with (__with__) {
  __hook__('w=', __with__, ['v', 1, (p) => v = p, v], _c_[0], false); // write access
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant