summaryrefslogtreecommitdiff
path: root/servers/visual
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2019-10-06 20:35:41 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2019-10-06 20:35:41 +0300
commit76324bec8d269330c59812bfcc852a195304aa92 (patch)
treec62a27f5de1e988951b0b228bb07f16036661996 /servers/visual
parentb71f23169af2c3ddefe6ddd76d63da54aea0d78c (diff)
Prevent shader crash if name of variable overrides function name
Diffstat (limited to 'servers/visual')
-rw-r--r--servers/visual/shader_language.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 25c12eafc5..ae99d64eee 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -2914,6 +2914,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
bool ok = _parse_function_arguments(p_block, p_builtin_types, func, &carg);
+ // Check if block has a variable with the same name as function to prevent shader crash.
+ ShaderLanguage::BlockNode *bnode = p_block;
+ while (bnode) {
+ if (bnode->variables.has(name)) {
+ _set_error("Expected function name");
+ return NULL;
+ }
+ bnode = bnode->parent_block;
+ }
+
//test if function was parsed first
for (int i = 0; i < shader->functions.size(); i++) {
if (shader->functions[i].name == name) {