summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2020-03-26 13:32:39 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2020-03-28 19:51:42 +0300
commitaa33db056a6f3fed2eab6092f23db7caaddb1cfc (patch)
tree4710015cb9197709273e06ab10617aec97fab323 /servers/rendering
parent0ecca1abd0716a5f876bed619b6abbbbf1d3f269 (diff)
Prevent shader crash if multiple variables has been declared in 'for'
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/shader_language.cpp5
-rw-r--r--servers/rendering/shader_language.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index cf2a01c07c..300c38db22 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -5070,6 +5070,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
p_block->variables[name] = var;
if (tk.type == TK_COMMA) {
+ if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR) {
+ _set_error("Multiple declarations in 'for' loop are not implemented yet.");
+ return ERR_PARSE_ERROR;
+ }
tk = _get_token();
//another variable
} else if (tk.type == TK_SEMICOLON) {
@@ -5394,6 +5398,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
cf->flow_op = FLOW_OP_FOR;
BlockNode *init_block = alloc_node<BlockNode>();
+ init_block->block_type = BlockNode::BLOCK_TYPE_FOR;
init_block->parent_block = p_block;
init_block->single_statement = true;
cf->blocks.push_back(init_block);
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index bdc15cc4aa..9124bee633 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -487,6 +487,7 @@ public:
enum BlockType {
BLOCK_TYPE_STANDART,
+ BLOCK_TYPE_FOR,
BLOCK_TYPE_SWITCH,
BLOCK_TYPE_CASE,
BLOCK_TYPE_DEFAULT,