From aa0b91ca527b0a35a4dc02466ec99ecba1b0160d 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 --- 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 416df39dde9..ce1e360443d 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 3f4ef7228a5..eaab81510b7 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 e9d773c246e..4d8aa5c2349 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 6bd31b3e3b5..dfaf8647c4c 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -928,6 +928,8 @@ String ShaderLanguage::get_datatype_name(DataType p_type) { return "samplerExternalOES"; case TYPE_STRUCT: return "struct"; + default: { + } } return ""; @@ -2703,6 +2705,8 @@ Variant ShaderLanguage::constant_value_to_variant(const Vector