From 01910bca3975fcb404e7990848b4dcc458b45f2c Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 5 Jul 2023 21:15:36 +0200 Subject: [PATCH] LibJS: Null check current scope pusher before register_identifier call This fixes crashing when current scope pusher is null during identifier parsing. --- Userland/Libraries/LibJS/Parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index d9ab8aa10f..3f8a809610 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -4988,7 +4988,8 @@ template NonnullRefPtr Parser::parse_function_node(u16, Opt NonnullRefPtr Parser::create_identifier_and_register_in_current_scope(SourceRange range, DeprecatedFlyString string) { auto id = create_ast_node(range, string); - m_state.current_scope_pusher->register_identifier(const_cast(*id)); + if (m_state.current_scope_pusher) + m_state.current_scope_pusher->register_identifier(const_cast(*id)); return id; }