Guard traversal of certain kinds of mid-optimization IfStatement

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>
This commit is contained in:
Brian Osman 2020-10-27 09:52:39 -04:00 committed by Skia Commit-Bot
parent fdf6148102
commit 5567a6091c

View File

@ -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()));
}