summaryrefslogtreecommitdiff
path: root/Libraries/LibRegex
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-11-28 09:27:59 +0330
committerAndreas Kling <kling@serenityos.org>2020-11-28 10:13:33 +0100
commite83e7a03c249c868b96b6a9dd10ad834a7c9af20 (patch)
tree1fbad83f6a02fe8e38b356ba9b7b655f5103aada /Libraries/LibRegex
parent2adcdbcc1ebd98a5e9b30106e15a2577ad24de02 (diff)
downloadserenity-e83e7a03c249c868b96b6a9dd10ad834a7c9af20.zip
LibRegex: Stop trying to read a character class when no tokens remain
e.g. in "[". Fixes #4186.
Diffstat (limited to 'Libraries/LibRegex')
-rw-r--r--Libraries/LibRegex/RegexParser.cpp5
1 files changed, 5 insertions, 0 deletions
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<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;