aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn3
-rw-r--r--src/sksl/SkSLLayoutLexer.cpp3
-rw-r--r--src/sksl/SkSLLexer.cpp3
-rw-r--r--src/sksl/lex/Main.cpp3
4 files changed, 12 insertions, 0 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 14ce04a298..2b333af09c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -429,6 +429,9 @@ if (skia_lex) {
action("run_sksllex") {
script = "gn/run_sksllex.py"
+ deps = [
+ ":sksllex(//gn/toolchain:$host_toolchain)",
+ ]
sources = [
"src/sksl/lex/layout.lex",
"src/sksl/lex/sksl.lex",
diff --git a/src/sksl/SkSLLayoutLexer.cpp b/src/sksl/SkSLLayoutLexer.cpp
index 27efa89d92..432095ab12 100644
--- a/src/sksl/SkSLLayoutLexer.cpp
+++ b/src/sksl/SkSLLayoutLexer.cpp
@@ -353,6 +353,9 @@ LayoutToken LayoutLexer::next() {
LayoutToken::Kind lastAccept = LayoutToken::Kind::INVALID;
int lastAcceptEnd = startOffset + 1;
while (offset < fLength) {
+ if ((uint8_t) fText[offset] >= 127) {
+ break;
+ }
state = transitions[mappings[(int)fText[offset]]][state];
++offset;
if (!state) {
diff --git a/src/sksl/SkSLLexer.cpp b/src/sksl/SkSLLexer.cpp
index 2b3d465cb3..c97ded924f 100644
--- a/src/sksl/SkSLLexer.cpp
+++ b/src/sksl/SkSLLexer.cpp
@@ -926,6 +926,9 @@ Token Lexer::next() {
Token::Kind lastAccept = Token::Kind::INVALID;
int lastAcceptEnd = startOffset + 1;
while (offset < fLength) {
+ if ((uint8_t) fText[offset] >= 127) {
+ break;
+ }
state = transitions[mappings[(int)fText[offset]]][state];
++offset;
if (!state) {
diff --git a/src/sksl/lex/Main.cpp b/src/sksl/lex/Main.cpp
index ff5d6619a1..fe06a874d3 100644
--- a/src/sksl/lex/Main.cpp
+++ b/src/sksl/lex/Main.cpp
@@ -141,6 +141,9 @@ void writeCPP(const DFA& dfa, const char* lexer, const char* token, const char*
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";