Ver Fonte

LibJS: Fix crash in Lexer on EOF in unterminated template literal

Fixes #4252.
Linus Groh há 4 anos atrás
pai
commit
ea08bf5812
1 ficheiros alterados com 4 adições e 2 exclusões
  1. 4 2
      Libraries/LibJS/Lexer.cpp

+ 4 - 2
Libraries/LibJS/Lexer.cpp

@@ -451,8 +451,10 @@ Token Lexer::next()
                     consume();
                 consume();
             }
-
-            token_type = TokenType::TemplateLiteralString;
+            if (is_eof() && !m_template_states.is_empty())
+                token_type = TokenType::UnterminatedTemplateLiteral;
+            else
+                token_type = TokenType::TemplateLiteralString;
         }
     } else if (is_identifier_start()) {
         // identifier or keyword