summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2023-04-13 21:12:59 +0330
committerAndreas Kling <kling@serenityos.org>2023-04-14 12:33:54 +0200
commiteba466b8e766bd69992b8cf2dcd300538713fda5 (patch)
treef69a9c60bd464cac6b02c914211545508ffadb40 /Tests
parent821702fadd551ffa987d7caae98ba10b18a8b153 (diff)
downloadserenity-eba466b8e766bd69992b8cf2dcd300538713fda5.zip
LibRegex: Avoid calling GenericLexer::consume() past EOF
The consume(size_t) overload consumes "at most" as many bytes as requested, but consume() consumes exactly one byte. This commit makes sure to avoid consuming past EOF. Fixes #18324. Fixes #18325.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LibRegex/Regex.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp
index 0e47191a18..44792ad4cc 100644
--- a/Tests/LibRegex/Regex.cpp
+++ b/Tests/LibRegex/Regex.cpp
@@ -606,6 +606,8 @@ TEST_CASE(ECMA262_parse)
{ "((?=lg)?[vl]k\\-?\\d{3}) bui| 3\\.[-\\w; ]{10}lg?-([06cv9]{3,4})"sv, regex::Error::NoError, ECMAScriptFlags::BrowserExtended }, // #12373, quantifiable assertions.
{ parse_test_case_long_disjunction_chain.view() }, // A whole lot of disjunctions, should not overflow the stack.
{ "(\"|')(?:(?!\\2)[^\\\\\\r\\n]|\\\\.)*\\2"sv, regex::Error::NoError, ECMAScriptFlags::BrowserExtended }, // LegacyOctalEscapeSequence should not consume too many chars (and should not crash)
+ // #18324, Capture group counter skipped past EOF.
+ { "\\1[\\"sv, regex::Error::InvalidNumber },
};
for (auto& test : tests) {