summaryrefslogtreecommitdiff
path: root/servers/visual
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2020-02-15 22:19:45 +0300
committerYuri Roubinsky <chaosus89@gmail.com>2020-02-15 22:19:45 +0300
commita1da8560eecf5bfbc6e050022541e43cf74231cd (patch)
tree6e1b97a5b8916d74f8997bad5ddb131ed3508ce9 /servers/visual
parent53cf289f309ef44821e5bb1fe0c81de29a82d9d3 (diff)
Fix shader crash if duplicated struct members created
Diffstat (limited to 'servers/visual')
-rw-r--r--servers/visual/shader_language.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index 734abd7365..a7c18f184d 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -5675,7 +5675,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
st.shader_struct = st_node;
int member_count = 0;
-
+ Set<String> member_names;
while (true) { // variables list
tk = _get_token();
if (tk.type == TK_CURLY_BRACKET_CLOSE) {
@@ -5732,6 +5732,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
member->struct_name = struct_name;
member->name = tk.text;
+ if (member_names.has(member->name)) {
+ _set_error("Redefinition of '" + String(member->name) + "'");
+ return ERR_PARSE_ERROR;
+ }
+ member_names.insert(member->name);
+
tk = _get_token();
if (tk.type == TK_BRACKET_OPEN) {
tk = _get_token();