mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
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.
This commit is contained in:
parent
821702fadd
commit
eba466b8e7
2 changed files with 8 additions and 1 deletions
|
@ -2695,17 +2695,22 @@ size_t ECMA262Parser::ensure_total_number_of_capturing_parenthesis()
|
|||
while (!lexer.is_eof()) {
|
||||
switch (lexer.peek()) {
|
||||
case '\\':
|
||||
lexer.consume(2);
|
||||
lexer.consume(min(lexer.tell_remaining(), 2));
|
||||
continue;
|
||||
case '[':
|
||||
while (!lexer.is_eof()) {
|
||||
if (lexer.consume_specific('\\')) {
|
||||
if (lexer.is_eof())
|
||||
break;
|
||||
lexer.consume();
|
||||
continue;
|
||||
}
|
||||
if (lexer.consume_specific(']')) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (lexer.is_eof())
|
||||
break;
|
||||
lexer.consume();
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue