From eec82d9f75395f86ac77d61c69d1066283e0554b Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Sun, 6 Jun 2021 14:59:52 +0300 Subject: [PATCH] Prevent shader crash when returning array when return type is scalar --- servers/rendering/shader_language.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index f485d79fb0f..8ed774f8e78 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -6375,13 +6375,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun } pass_array = false; - bool array_size_incorrect = false; - - if (b->parent_function->return_array_size > 0 && b->parent_function->return_array_size != expr->get_array_size()) { - array_size_incorrect = true; - } - - if (b->parent_function->return_type != expr->get_datatype() || array_size_incorrect || return_struct_name != expr->get_datatype_name()) { + if (b->parent_function->return_type != expr->get_datatype() || b->parent_function->return_array_size != expr->get_array_size() || return_struct_name != expr->get_datatype_name()) { _set_error("Expected return with an expression of type '" + (return_struct_name != "" ? return_struct_name : get_datatype_name(b->parent_function->return_type)) + array_size_string + "'"); return ERR_PARSE_ERROR; }