[PATCH] D135356: [Format] Fix crash when hitting eof while lexing JS template string

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 04:25:06 PDT 2022


kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!



================
Comment at: clang/lib/Format/FormatTokenLexer.cpp:767
     if (Offset[0] == '\\') {
       ++Offset; // Skip the escaped character.
     } else if (Offset + 1 < Lex->getBuffer().end() && Offset[0] == '$' &&
----------------
it's a separate concern, but feels like this could also trigger some crashes (e.g. an input like "`\")


================
Comment at: clang/lib/Format/FormatTokenLexer.cpp:772
       StateStack.push(LexerState::NORMAL);
       ++Offset;
+      ++Offset;
----------------
nit: `Offset += 2;` instead?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135356/new/

https://reviews.llvm.org/D135356



More information about the cfe-commits mailing list