diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2020-02-15 22:19:45 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2020-02-15 22:19:45 +0300 |
commit | a1da8560eecf5bfbc6e050022541e43cf74231cd (patch) | |
tree | 6e1b97a5b8916d74f8997bad5ddb131ed3508ce9 /servers/visual | |
parent | 53cf289f309ef44821e5bb1fe0c81de29a82d9d3 (diff) |
Fix shader crash if duplicated struct members created
Diffstat (limited to 'servers/visual')
-rw-r--r-- | servers/visual/shader_language.cpp | 8 |
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(); |