diff options
author | ethannicholas <ethannicholas@google.com> | 2016-10-14 08:37:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-14 08:37:32 -0700 |
commit | a54401da547def2e6e058df3ee2a03a843fb40ae (patch) | |
tree | e0247b705b6fd1776c0f21761445f8178d283903 /src | |
parent | 3a2e45a6ed50c07cb1a710d3f7b74be796e61251 (diff) |
fix skslc crashes uncovered by fuzz testing
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2413423003
Review-Url: https://codereview.chromium.org/2413423003
Diffstat (limited to 'src')
-rw-r--r-- | src/sksl/SkSLIRGenerator.cpp | 1 | ||||
-rw-r--r-- | src/sksl/SkSLParser.cpp | 19 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp index 6307087edd..9a42379065 100644 --- a/src/sksl/SkSLIRGenerator.cpp +++ b/src/sksl/SkSLIRGenerator.cpp @@ -1228,6 +1228,7 @@ std::unique_ptr<Expression> IRGenerator::convertSuffixExpression( *newType)); } else { fErrors.error(expression.fPosition, "'[]' must follow a type name"); + return nullptr; } } case ASTSuffix::kCall_Kind: { diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp index 9e3e84784b..d011d46947 100644 --- a/src/sksl/SkSLParser.cpp +++ b/src/sksl/SkSLParser.cpp @@ -808,17 +808,26 @@ std::unique_ptr<ASTForStatement> Parser::forStatement() { case Token::SEMICOLON: this->nextToken(); break; - case Token::CONST: + case Token::CONST: { + std::unique_ptr<ASTVarDeclarations> vd = this->varDeclarations(); + if (!vd) { + return nullptr; + } initializer = std::unique_ptr<ASTStatement>(new ASTVarDeclarationStatement( - this->varDeclarations())); + std::move(vd))); break; - case Token::IDENTIFIER: + } + case Token::IDENTIFIER: { if (this->isType(nextToken.fText)) { + std::unique_ptr<ASTVarDeclarations> vd = this->varDeclarations(); + if (!vd) { + return nullptr; + } initializer = std::unique_ptr<ASTStatement>(new ASTVarDeclarationStatement( - this->varDeclarations())); + std::move(vd))); break; } - // fall through + } // fall through default: initializer = this->expressionStatement(); } |