瀏覽代碼

LibJS: Null check current scope pusher before register_identifier call

This fixes crashing when current scope pusher is null during identifier
parsing.
Aliaksandr Kalenik 2 年之前
父節點
當前提交
01910bca39
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Userland/Libraries/LibJS/Parser.cpp

+ 2 - 1
Userland/Libraries/LibJS/Parser.cpp

@@ -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;
 }