LibJS: Remove ParserState::lookahead_lexer

The lookahead lexer used by next_token() no longer needs to be kept
alive, since tokens created by Parser::next_token() now have any string
views guaranteed safe by the fact that they point into the one true
SourceCode provided by whoever set up the lexer.
This commit is contained in:
Andreas Kling 2025-11-08 21:24:56 +01:00 committed by Andreas Kling
parent 0dacc94edd
commit fa44fd58d8
Notes: github-actions[bot] 2025-11-09 11:15:16 +00:00
2 changed files with 2 additions and 5 deletions

View file

@ -4291,10 +4291,8 @@ bool Parser::match_declaration(AllowUsingDeclaration allow_using) const
Token Parser::next_token() const
{
// We need to keep the lookahead lexer alive to prevent UAF on the lookahead token, as the token may hold a view
// into a short string stored on the stack.
m_state.lookahead_lexer = m_state.lexer;
return m_state.lookahead_lexer->next();
auto lookahead_lexer = m_state.lexer;
return lookahead_lexer.next();
}
bool Parser::try_match_let_declaration() const