From 37af1d74cc32166c8bcbd971eb3065b9b6ca5ed7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 4 Apr 2020 11:00:14 +0200 Subject: LibGUI: Fix CppLexer assertion on incomplete #include statements Thanks to @NotKyon for reporting this bug with a solid analysis. Fixes #1488. --- Libraries/LibGUI/CppLexer.cpp | 10 +++++----- 1 file 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 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(); } } -- cgit v1.2.3