summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2020-06-27 09:24:49 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2020-06-27 17:36:45 +0300
commit2ce77e4b57a1c1c3f85d84aab238973336a3c282 (patch)
treee03b745beee8f5bd30d8cf45e277debc7911d1b3 /servers
parenta4e200a47a151ed5ce1627a17ce694048987eadf (diff)
Prevents usage of return in main shader functions
Diffstat (limited to 'servers')
-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;
}