diff options
author | Linus Groh <mail@linusgroh.de> | 2020-11-29 22:59:06 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-30 11:36:42 +0100 |
commit | ea08bf581260e51d5a5929d7db89472dec79dd04 (patch) | |
tree | 601d6733c8c47d009c0abfb0e9571c0f59fc11ec | |
parent | 8284f878673cf2419a707c25f3eaf45aeb0229cb (diff) | |
download | serenity-ea08bf581260e51d5a5929d7db89472dec79dd04.zip |
LibJS: Fix crash in Lexer on EOF in unterminated template literal
Fixes #4252.
-rw-r--r-- | Libraries/LibJS/Lexer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Libraries/LibJS/Lexer.cpp b/Libraries/LibJS/Lexer.cpp index c9eeebd3a2..74af67b9ea 100644 --- a/Libraries/LibJS/Lexer.cpp +++ b/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 |