From d6812ff7b98fa838f343e6c284b05817f73aa1d6 Mon Sep 17 00:00:00 2001 From: dzil123 <5725958+dzil123@users.noreply.github.com> Date: Wed, 16 Nov 2022 06:33:40 -0800 Subject: [PATCH] [3.x] Fix shader compiler asan out of bounds (cherry picked from commit aa0b91ca527b0a35a4dc02466ec99ecba1b0160d) --- drivers/gles2/rasterizer_storage_gles2.cpp | 3 +++ drivers/gles3/rasterizer_storage_gles3.cpp | 2 ++ drivers/gles3/shader_compiler_gles3.cpp | 4 ++++ servers/visual/shader_language.cpp | 24 ++++++++++++++++++++++ servers/visual/shader_language.h | 1 + 5 files changed, 34 insertions(+) diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index b10e20e0367..82337e6ca4c 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -1680,6 +1680,9 @@ void RasterizerStorageGLES2::shader_get_param_list(RID p_shader, Listpush_back(pi); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 0504459480f..996ebed0ded 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2460,6 +2460,8 @@ void RasterizerStorageGLES3::shader_get_param_list(RID p_shader, Listpush_back(pi); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index c7403e5ca55..e4306efe86d 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -114,6 +114,8 @@ static int _get_datatype_size(SL::DataType p_type) { return 16; case SL::TYPE_STRUCT: return 0; + default: { + } } ERR_FAIL_V(0); @@ -185,6 +187,8 @@ static int _get_datatype_alignment(SL::DataType p_type) { return 16; case SL::TYPE_STRUCT: return 0; + default: { + } } ERR_FAIL_V(0); diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index edb8a7514e4..4c8beea0385 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -926,6 +926,8 @@ String ShaderLanguage::get_datatype_name(DataType p_type) { return "samplerExternalOES"; case TYPE_STRUCT: return "struct"; + default: { + } } return ""; @@ -2701,6 +2703,8 @@ Variant ShaderLanguage::constant_value_to_variant(const Vector