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(); } }