diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-04 11:00:14 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-04 11:00:14 +0200 |
commit | 37af1d74cc32166c8bcbd971eb3065b9b6ca5ed7 (patch) | |
tree | a0f34e855b3544ea12194c95d0cacb718bd17790 | |
parent | a502ba73dc5bcad6dc010bf80f9bdff20910bcd1 (diff) | |
download | serenity-37af1d74cc32166c8bcbd971eb3065b9b6ca5ed7.zip |
LibGUI: Fix CppLexer assertion on incomplete #include statements
Thanks to @NotKyon for reporting this bug with a solid analysis.
Fixes #1488.
-rw-r--r-- | Libraries/LibGUI/CppLexer.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Libraries/LibGUI/CppLexer.cpp b/Libraries/LibGUI/CppLexer.cpp index fcf5bd7f8c..c901437d00 100644 --- a/Libraries/LibGUI/CppLexer.cpp +++ b/Libraries/LibGUI/CppLexer.cpp @@ -363,16 +363,16 @@ Vector<CppToken> CppLexer::lex() begin_token(); if (peek() == '<' || peek() == '"') { char closing = consume() == '<' ? '>' : '"'; - while (peek() != closing && peek() != '\n') + while (peek() && peek() != closing && peek() != '\n') consume(); - if (consume() == '\n') { + if (peek() && consume() == '\n') { commit_token(CppToken::Type::IncludePath); continue; - } else { - commit_token(CppToken::Type::IncludePath); - begin_token(); } + + commit_token(CppToken::Type::IncludePath); + begin_token(); } } |