LibJS: Null check current scope pusher before register_identifier call

This fixes crashing when current scope pusher is null during identifier
parsing.
This commit is contained in:
Aliaksandr Kalenik 2023-07-05 21:15:36 +02:00 committed by Andreas Kling
parent ae3a7fd4b8
commit 01910bca39
Notes: sideshowbarker 2024-07-17 11:34:34 +09:00

View file

@ -4988,7 +4988,8 @@ template NonnullRefPtr<FunctionDeclaration> Parser::parse_function_node(u16, Opt
NonnullRefPtr<Identifier const> Parser::create_identifier_and_register_in_current_scope(SourceRange range, DeprecatedFlyString string)
{
auto id = create_ast_node<Identifier const>(range, string);
m_state.current_scope_pusher->register_identifier(const_cast<Identifier&>(*id));
if (m_state.current_scope_pusher)
m_state.current_scope_pusher->register_identifier(const_cast<Identifier&>(*id));
return id;
}