Browse Source

LibRegex: Stop trying to read a character class when no tokens remain

e.g. in "[".
Fixes #4186.
AnotherTest 4 năm trước cách đây
mục cha
commit
e83e7a03c2
1 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 5 0
      Libraries/LibRegex/RegexParser.cpp

+ 5 - 0
Libraries/LibRegex/RegexParser.cpp

@@ -1236,6 +1236,11 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
     };
 
     while (!match(TokenType::RightBracket)) {
+        if (match(TokenType::Eof)) {
+            set_error(Error::MismatchingBracket);
+            return false;
+        }
+
         auto first_atom = read_class_atom();
         if (!first_atom.has_value())
             return false;