fix for SkSL lexer crash on non-ASCII input
Bug: skia:7126
Change-Id: Ic884d14daf91fd668afe9e29d2f82d1ef1089cce
Reviewed-on: https://skia-review.googlesource.com/56720
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/lex/Main.cpp b/src/sksl/lex/Main.cpp
index ff5d661..fe06a87 100644
--- a/src/sksl/lex/Main.cpp
+++ b/src/sksl/lex/Main.cpp
@@ -141,6 +141,9 @@
out << " " << token << "::Kind lastAccept = " << token << "::Kind::INVALID;\n";
out << " int lastAcceptEnd = startOffset + 1;\n";
out << " while (offset < fLength) {\n";
+ out << " if ((uint8_t) fText[offset] >= " << dfa.fCharMappings.size() << ") {";
+ out << " break;";
+ out << " }";
out << " state = transitions[mappings[(int) fText[offset]]][state];\n";
out << " ++offset;\n";
out << " if (!state) {\n";