From 30db7813dedcb16afa67a9c9b6d4f39e04bce536 Mon Sep 17 00:00:00 2001 From: Sasan Hezarkhani Date: Sun, 1 Dec 2019 22:47:09 -0800 Subject: [PATCH] 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. --- DevTools/HackStudio/CppLexer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/DevTools/HackStudio/CppLexer.cpp b/DevTools/HackStudio/CppLexer.cpp index d9b5744ba1..e92bdfb488 100644 --- a/DevTools/HackStudio/CppLexer.cpp +++ b/DevTools/HackStudio/CppLexer.cpp @@ -278,13 +278,21 @@ Vector 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; }