mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 01:29:17 +00:00
HackStudio: Fixes CppLexer crashing on a comment block that does
not end. CppLexer expected that `/*` always has `*/` at the end. This PR fixes the issue and assumes the rest of file is a comment.
This commit is contained in:
parent
f4949fcf83
commit
30db7813de
Notes:
sideshowbarker
2024-07-19 10:59:55 +09:00
Author: https://github.com/gootik 🔰
Commit: 30db7813de
Pull-request: https://github.com/SerenityOS/serenity/pull/837
1 changed files with 11 additions and 3 deletions
|
@ -278,13 +278,21 @@ Vector<CppToken> CppLexer::lex()
|
||||||
begin_token();
|
begin_token();
|
||||||
consume();
|
consume();
|
||||||
consume();
|
consume();
|
||||||
|
bool comment_block_ends = false;
|
||||||
while (peek()) {
|
while (peek()) {
|
||||||
if (peek() == '*' && peek(1) == '/')
|
if (peek() == '*' && peek(1) == '/') {
|
||||||
|
comment_block_ends = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
consume();
|
consume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comment_block_ends) {
|
||||||
consume();
|
consume();
|
||||||
consume();
|
consume();
|
||||||
|
}
|
||||||
|
|
||||||
commit_token(CppToken::Type::Comment);
|
commit_token(CppToken::Type::Comment);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue