summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-06-27 17:03:42 +0200
committerGitHub <noreply@github.com>2020-06-27 17:03:42 +0200
commitff0583770a8152cd63265e26e2529a170c179f68 (patch)
tree7fe4a1c6e4dfe26f2299d30236ef4bc62af2e2d4 /servers/rendering
parentc4707bd71bedb461a99112d01bf80239f5ceac56 (diff)
parent2ce77e4b57a1c1c3f85d84aab238973336a3c282 (diff)
Merge pull request #39869 from Chaosus/shader_fix_return
Prevents usage of return in main shader functions
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/shader_language.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 14a28554f9..809b03520b 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -5585,6 +5585,12 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
} else if (tk.type == TK_CF_RETURN) {
//check return type
BlockNode *b = p_block;
+
+ if (b && b->parent_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;
}