diff --git a/src/sksl/dsl/DSLType.cpp b/src/sksl/dsl/DSLType.cpp index 109e0f41bc..7a24797d25 100644 --- a/src/sksl/dsl/DSLType.cpp +++ b/src/sksl/dsl/DSLType.cpp @@ -187,7 +187,13 @@ DSLExpression DSLType::Construct(DSLType type, SkTArray argArray) } DSLType Array(const DSLType& base, int count) { - SkASSERT(count >= 1); + if (count <= 0) { + DSLWriter::ReportError("error: array size must be positive\n"); + } + if (base.isArray()) { + DSLWriter::ReportError("error: multidimensional arrays are not permitted\n"); + return base; + } return DSLWriter::SymbolTable()->addArrayDimension(&base.skslType(), count); } diff --git a/tests/SkSLDSLTest.cpp b/tests/SkSLDSLTest.cpp index dbd55ca160..216d27edd6 100644 --- a/tests/SkSLDSLTest.cpp +++ b/tests/SkSLDSLTest.cpp @@ -556,6 +556,16 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLType, r, ctxInfo) { DSLExpression e = x + 1; REPORTER_ASSERT(r, e.type().isFloat()); e.release(); + + { + ExpectError error(r, "error: array size must be positive\n"); + Array(kFloat_Type, -1); + } + + { + ExpectError error(r, "error: multidimensional arrays are not permitted\n"); + Array(Array(kFloat_Type, 2), 2); + } } DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLMatrices, r, ctxInfo) {