skia2/tests/CrbugOssfuzz21688.cpp
John Stiles 57a996b4c5 Disallow empty interface blocks in SkSL.
The GLSL grammar appears to require at least one member-declaration in the member-list:
https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.html#interface-blocks

Change-Id: Ic67469272b3d59e7b8764333899f204e95584778
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284418
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-04-21 20:36:54 +00:00

31 lines
1.1 KiB
C++

/*
* Copyright 2020 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tests/Test.h"
#include <memory>
#include "src/gpu/GrShaderCaps.h"
#include "src/sksl/SkSLCompiler.h"
#include "src/sksl/SkSLString.h"
#include "src/sksl/ir/SkSLProgram.h"
DEF_TEST(crbug_ossfuzz_21688_interfaceblock, reporter) {
// Tests that arrays of zero-sized interface blocks are disallowed.
SkSL::Compiler compiler;
SkSL::String output;
SkSL::Program::Settings settings;
sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
settings.fCaps = caps.get();
const char* const kProgramText = "testBlock {} x[2];";
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(SkSL::Program::kFragment_Kind,
kProgramText, settings);
REPORTER_ASSERT(reporter, program == nullptr);
REPORTER_ASSERT(reporter, compiler.errorText().find("interface block 'testBlock' must "
"contain at least one member") != -1);
}