From 5928cc90f8af3f379eaa5ad0faf1dc3b78ac3a44 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Tue, 23 Nov 2021 10:40:47 +0300 Subject: [PATCH] [3.x] Prevent return statement from using in block in shader main func --- servers/visual/shader_language.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 559edc22829..70863dc86ce 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -5385,11 +5385,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Mapparent_function && (b->parent_function->name == "vertex" || b->parent_function->name == "fragment" || b->parent_function->name == "light")) { - _set_error(vformat("Using 'return' in '%s' processor function results in undefined behavior!", b->parent_function->name)); - return ERR_PARSE_ERROR; - } - while (b && !b->parent_function) { b = b->parent_block; } @@ -5399,6 +5394,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Mapparent_function && (b->parent_function->name == "vertex" || b->parent_function->name == "fragment" || b->parent_function->name == "light")) { + _set_error(vformat("Using 'return' in '%s' processor function results in undefined behavior!", b->parent_function->name)); + return ERR_PARSE_ERROR; + } + String return_struct_name = String(b->parent_function->return_struct_name); ControlFlowNode *flow = alloc_node();