John Stiles | 0ebc69c | 2020-04-17 21:43:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "tests/Test.h" |
| 9 | |
| 10 | #include <memory> |
| 11 | |
| 12 | #include "src/gpu/GrShaderCaps.h" |
| 13 | #include "src/sksl/SkSLCompiler.h" |
| 14 | #include "src/sksl/SkSLString.h" |
| 15 | #include "src/sksl/ir/SkSLProgram.h" |
| 16 | |
John Stiles | 57a996b | 2020-04-19 19:05:12 -0700 | [diff] [blame] | 17 | DEF_TEST(crbug_ossfuzz_21688_interfaceblock, reporter) { |
| 18 | // Tests that arrays of zero-sized interface blocks are disallowed. |
John Stiles | 0ebc69c | 2020-04-17 21:43:10 -0700 | [diff] [blame] | 19 | SkSL::Compiler compiler; |
| 20 | SkSL::String output; |
| 21 | SkSL::Program::Settings settings; |
| 22 | sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default(); |
| 23 | settings.fCaps = caps.get(); |
John Stiles | 57a996b | 2020-04-19 19:05:12 -0700 | [diff] [blame] | 24 | const char* const kProgramText = "testBlock {} x[2];"; |
| 25 | std::unique_ptr<SkSL::Program> program = compiler.convertProgram(SkSL::Program::kFragment_Kind, |
| 26 | kProgramText, settings); |
| 27 | REPORTER_ASSERT(reporter, program == nullptr); |
| 28 | REPORTER_ASSERT(reporter, compiler.errorText().find("interface block 'testBlock' must " |
| 29 | "contain at least one member") != -1); |
John Stiles | 0ebc69c | 2020-04-17 21:43:10 -0700 | [diff] [blame] | 30 | } |