summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-02-21 12:02:56 +0100
committerGitHub <noreply@github.com>2021-02-21 12:02:56 +0100
commitb87f44878583dfe37dfa45931360867bf74ced7f (patch)
tree1d551f523b2f262272df29640aebce93613cfdeb
parent3bb628d8fe26abad258a222a5e22b644e2b73a01 (diff)
parent571f4396ea7512b792f92d46fb528ba3909641d2 (diff)
Merge pull request #46275 from Chaosus/shader_fix_struct_crash
Prevents shader crash if two struct with the same name are declared
-rw-r--r--servers/rendering/shader_language.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 1f0cf5959f..cb98a71e86 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -6135,6 +6135,10 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
tk = _get_token();
if (tk.type == TK_IDENTIFIER) {
st.name = tk.text;
+ if (shader->structs.has(st.name)) {
+ _set_error("Redefinition of '" + String(st.name) + "'");
+ return ERR_PARSE_ERROR;
+ }
tk = _get_token();
if (tk.type != TK_CURLY_BRACKET_OPEN) {
_set_error("Expected '{'");