summaryrefslogtreecommitdiff
path: root/servers/rendering
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-07-26 17:38:14 +0200
committerGitHub <noreply@github.com>2021-07-26 17:38:14 +0200
commitfef27e9b5b9b125ff535513c80b45953e8717f7d (patch)
tree32d6f0bc18ce71cb84acb07b9566beaa8237bf89 /servers/rendering
parent8f6c16e4a459b54d6b37bc64e0bd21a361078a01 (diff)
parentc082982a47624b1a451a062562bb9b788ad63331 (diff)
Merge pull request #50895 from Chaosus/fix_shader_crash
Fix editor crash if passing index as variable to function parameter
Diffstat (limited to 'servers/rendering')
-rw-r--r--servers/rendering/shader_language.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index c9bdec688d..baa5381554 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -4796,10 +4796,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
String member_struct_name;
if (expr->get_array_size() > 0) {
- uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
- if (index_constant >= (uint32_t)expr->get_array_size()) {
- _set_error(vformat("Index [%s] out of range [%s..%s]", index_constant, 0, expr->get_array_size() - 1));
- return nullptr;
+ if (index->type == Node::TYPE_CONSTANT) {
+ uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
+ if (index_constant >= (uint32_t)expr->get_array_size()) {
+ _set_error(vformat("Index [%s] out of range [%s..%s]", index_constant, 0, expr->get_array_size() - 1));
+ return nullptr;
+ }
}
member_type = expr->get_datatype();
if (member_type == TYPE_STRUCT) {