Преглед изворни кода

LibGUI: Fix CppLexer assertion on incomplete #include statements

Thanks to @NotKyon for reporting this bug with a solid analysis.

Fixes #1488.
Andreas Kling пре 5 година
родитељ
комит
37af1d74cc
1 измењених фајлова са 5 додато и 5 уклоњено
  1. 5 5
      Libraries/LibGUI/CppLexer.cpp

+ 5 - 5
Libraries/LibGUI/CppLexer.cpp

@@ -363,16 +363,16 @@ Vector<CppToken> CppLexer::lex()
                 begin_token();
                 begin_token();
                 if (peek() == '<' || peek() == '"') {
                 if (peek() == '<' || peek() == '"') {
                     char closing = consume() == '<' ? '>' : '"';
                     char closing = consume() == '<' ? '>' : '"';
-                    while (peek() != closing && peek() != '\n')
+                    while (peek() && peek() != closing && peek() != '\n')
                         consume();
                         consume();
 
 
-                    if (consume() == '\n') {
+                    if (peek() && consume() == '\n') {
                         commit_token(CppToken::Type::IncludePath);
                         commit_token(CppToken::Type::IncludePath);
                         continue;
                         continue;
-                    } else {
-                        commit_token(CppToken::Type::IncludePath);
-                        begin_token();
                     }
                     }
+
+                    commit_token(CppToken::Type::IncludePath);
+                    begin_token();
                 }
                 }
             }
             }