aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-10-14 08:37:32 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-14 08:37:32 -0700
commita54401da547def2e6e058df3ee2a03a843fb40ae (patch)
treee0247b705b6fd1776c0f21761445f8178d283903
parent3a2e45a6ed50c07cb1a710d3f7b74be796e61251 (diff)
fix skslc crashes uncovered by fuzz testing
-rw-r--r--src/sksl/SkSLIRGenerator.cpp1
-rw-r--r--src/sksl/SkSLParser.cpp19
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();
}