Skip to content

Prevent arguments object creation if 'arguments' function argument is present #4849

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

Merged

Conversation

rerobika
Copy link
Member

@rerobika rerobika commented Dec 7, 2021

This patch fixes #4847.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]

@rerobika rerobika added bug Undesired behaviour pre-scanner Related to the JavaScript pre-scanner labels Dec 7, 2021
@rerobika rerobika force-pushed the fix_arguments_object_creation branch 2 times, most recently from d8d2ec7 to fbb1d4c Compare December 7, 2021 11:30
@rerobika rerobika changed the title Prevent arguments object creation if arguments parameter is present Prevent arguments object creation if 'arguments' function argument is present Dec 7, 2021
… present

This patch fixes jerryscript-project#4847.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
@rerobika rerobika force-pushed the fix_arguments_object_creation branch from fbb1d4c to 3bb042b Compare December 7, 2021 11:38
{
/* 'arguments' function argument existence should prevent the arguments object construction */
new_literal_pool_p->status_flags =
(uint16_t) (new_literal_pool_p->status_flags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect style.

@@ -1246,6 +1246,7 @@ scanner_filter_arguments (parser_context_t *context_p, /**< context */

if (has_arguments)
{
/* Force the lexically stored arguments object creation */
literal_pool_p->status_flags |= (SCANNER_LITERAL_POOL_ARGUMENTS_IN_ARGS | SCANNER_LITERAL_POOL_NO_ARGUMENTS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put the argument checking as a for loop here since the while (true) loop might also exit. This case is rare, so an extra loop should not cost much.

@zherczeg
Copy link
Member

zherczeg commented Dec 7, 2021

Note:

function f(arguments, eval = () => eval('')) { }

still crashes

rerobika pushed a commit to rerobika/jerryscript that referenced this pull request Dec 8, 2021
This patch is the followup of jerryscript-project#4849.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
rerobika pushed a commit to rerobika/jerryscript that referenced this pull request Dec 8, 2021
This patch is the followup of jerryscript-project#4849.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
ossy-szeged pushed a commit that referenced this pull request Dec 15, 2021
This patch is the followup of #4849.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour pre-scanner Related to the JavaScript pre-scanner
Projects
None yet
4 participants