From b0356bcb72a4647699c8e9c7ab1370f563ef81bc Mon Sep 17 00:00:00 2001 From: Yuri Roubinsky Date: Thu, 13 Jan 2022 14:39:35 +0300 Subject: [PATCH] Prevent redefinition of main functions in shader --- servers/rendering/shader_language.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index adbcdedaccf..c4d9ba4260f 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -8774,6 +8774,13 @@ Error ShaderLanguage::_parse_shader(const Map &p_funct } } + for (int i = 0; i < shader->functions.size(); i++) { + if (!shader->functions[i].callable && shader->functions[i].name == name) { + _set_error("Redefinition of '" + String(name) + "'"); + return ERR_PARSE_ERROR; + } + } + ShaderNode::Function function; function.callable = !p_functions.has(name);