Skip to content

Commit 84d503b

Browse files
Report an SkSL error if an in var has an initializer expression.
This resolves the fuzzer error, as the program will fail compilation before reaching the SPIR-V translation stage at all. Change-Id: Ia73af497b1f57314a29878f2d2a29dc80186e630 Bug: oss-fuzz:27300 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333130 Commit-Queue: John Stiles <[email protected]> Auto-Submit: John Stiles <[email protected]> Reviewed-by: Brian Osman <[email protected]>
1 parent 823b153 commit 84d503b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/sksl/SkSLIRGenerator.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ StatementArray IRGenerator::convertVarDeclarations(const ASTNode& decls,
395395
}
396396
String name(type->name());
397397
int64_t count;
398-
if (size->kind() == Expression::Kind::kIntLiteral) {
398+
if (size->is<IntLiteral>()) {
399399
count = size->as<IntLiteral>().value();
400400
if (count <= 0) {
401401
fErrors.error(size->fOffset, "array size must be positive");
@@ -428,6 +428,9 @@ StatementArray IRGenerator::convertVarDeclarations(const ASTNode& decls,
428428
if (!value) {
429429
return {};
430430
}
431+
if (modifiers.fFlags & Modifiers::kIn_Flag) {
432+
fErrors.error(value->fOffset, "'in' variables cannot use initializer expressions");
433+
}
431434
value = this->coerce(std::move(value), *type);
432435
if (!value) {
433436
return {};
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
### Compilation failed:
12

2-
in float x = 1.0;
3-
in float z = y = 1.0;
3+
error: 1: 'in' variables cannot use initializer expressions
4+
1 error

0 commit comments

Comments
 (0)