소스 검색

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.

Sasan Hezarkhani 5 년 전
부모
커밋
30db7813de
1개의 변경된 파일11개의 추가작업 그리고 3개의 파일을 삭제
  1. 11 3
      DevTools/HackStudio/CppLexer.cpp

+ 11 - 3
DevTools/HackStudio/CppLexer.cpp

@@ -278,13 +278,21 @@ Vector<CppToken> CppLexer::lex()
             begin_token();
             consume();
             consume();
+            bool comment_block_ends = false;
             while (peek()) {
-                if (peek() == '*' && peek(1) == '/')
+                if (peek() == '*' && peek(1) == '/') {
+                    comment_block_ends = true;
                     break;
+                }
+
                 consume();
             }
-            consume();
-            consume();
+
+            if (comment_block_ends) {
+                consume();
+                consume();
+            }
+
             commit_token(CppToken::Type::Comment);
             continue;
         }