From e83e7a03c249c868b96b6a9dd10ad834a7c9af20 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 28 Nov 2020 09:27:59 +0330 Subject: LibRegex: Stop trying to read a character class when no tokens remain e.g. in "[". Fixes #4186. --- Libraries/LibRegex/RegexParser.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Libraries/LibRegex') diff --git a/Libraries/LibRegex/RegexParser.cpp b/Libraries/LibRegex/RegexParser.cpp index 485a0902d6..785084ca0f 100644 --- a/Libraries/LibRegex/RegexParser.cpp +++ b/Libraries/LibRegex/RegexParser.cpp @@ -1236,6 +1236,11 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector& }; 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; -- cgit v1.2.3