From ae8de1f2ceadd81717979139661cd0005f91f060 Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Sat, 15 Feb 2020 22:19:45 +0300 Subject: [PATCH] Fix shader crash if duplicated struct members created --- servers/visual/shader_language.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index a042640a5df..c1759251ed5 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -5620,7 +5620,7 @@ Error ShaderLanguage::_parse_shader(const Map &p_funct st.shader_struct = st_node; int member_count = 0; - + Set member_names; while (true) { // variables list tk = _get_token(); if (tk.type == TK_CURLY_BRACKET_CLOSE) { @@ -5677,6 +5677,12 @@ Error ShaderLanguage::_parse_shader(const Map &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();