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>
This commit is contained in:
parent
84366d22d6
commit
e148bf714e
3
BUILD.gn
3
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",
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user