Skip to content

Commit

Permalink
Guard traversal of certain kinds of mid-optimization IfStatement
Browse files Browse the repository at this point in the history
When the test expression has a side-effect, but both the true and else
blocks are empty, the optimizer moves the test out to a standalone
ExpressionStatement. Updating the usage in that situation involves
traversing an IfStatement with no test.

Bug: oss-fuzz:26666
Change-Id: I2fb4004f2401784402040345df49a7d42e4aab5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/329960
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
  • Loading branch information
brianosman authored and Skia Commit-Bot committed Oct 27, 2020
1 parent fdf6148 commit 5567a60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/sksl/SkSLAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ bool TProgramVisitor<PROG, EXPR, STMT, ELEM>::visitStatement(STMT s) {
}
case Statement::Kind::kIf: {
auto& i = s.template as<IfStatement>();
return this->visitExpression(*i.test()) ||
return (i.test() && this->visitExpression(*i.test())) ||
(i.ifTrue() && this->visitStatement(*i.ifTrue())) ||
(i.ifFalse() && this->visitStatement(*i.ifFalse()));
}
Expand Down

0 comments on commit 5567a60

Please sign in to comment.