Fix assertion discovered by fuzzer.
We now stop processing a var-declaration if its array-size expression is
invalid. Previously, we'd pass a null array-size expression into
convertVar, which would assert (but would fail cleanly afterwards).
Change-Id: I976f3326e32afbc7045a86d73c0dcb28f418a6f4
Bug: oss-fuzz:37457
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441079
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index e82e9c0..c4eeb8c 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -411,12 +411,14 @@
std::unique_ptr<Expression> value;
auto iter = varDecl.begin();
if (iter != varDecl.end() && varData.fIsArray) {
- if (*iter) {
- arraySize = this->convertExpression(*iter++);
- } else {
+ if (!*iter) {
this->errorReporter().error(decls.fOffset, "array must have a size");
continue;
}
+ arraySize = this->convertExpression(*iter++);
+ if (!arraySize) {
+ continue;
+ }
}
if (iter != varDecl.end()) {
value = this->convertExpression(*iter);