Skip to content

Conversation

primavera-dolce
Copy link

When a class static block ends at EOF (no trailing newline), the caller unconditionally consumed the next char after '}', causing a 1-byte OOB read in lexer_consume_next_character. Guard at the call site and raise the same parse error the next stage expects.

JerryScript-DCO-1.0-Signed-off-by: Harriet Zhu [email protected]

PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING

…ript-project#5254)

When a class static block ends at EOF (no trailing newline), the caller
unconditionally consumed the next char after '}', causing a 1-byte OOB read
in lexer_consume_next_character. Guard at the call site and raise the same
parse error the next stage expects.

JerryScript-DCO-1.0-Signed-off-by: Harriet Zhu [email protected]
fields_size += sizeof (scanner_location_t);

lexer_consume_next_character (context_p);

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Comment on lines +865 to +868
else
{
lexer_consume_next_character (context_p);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we don't need else as parser_raise_error will stop the execution.

Suggested change
else
{
lexer_consume_next_character (context_p);
}
lexer_consume_next_character (context_p);

@seanshpark
Copy link
Contributor

seanshpark commented Oct 22, 2025

How about adding test .js file in tests/jerry like #5244 ?
I'm not sure current test framework can solve adding regression test for this case...


lexer_consume_next_character (context_p);

if (JERRY_UNLIKELY(context_p->source_p >= context_p->source_end_p))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (JERRY_UNLIKELY(context_p->source_p >= context_p->source_end_p))
if (JERRY_UNLIKELY (context_p->source_p >= context_p->source_end_p))

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

Successfully merging this pull request may close these issues.

2 participants