diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2019-10-06 18:35:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-06 18:35:07 +0300 |
commit | b71f23169af2c3ddefe6ddd76d63da54aea0d78c (patch) | |
tree | 214335c219a2ae6f30db0854bf3e003a40b146e8 /servers | |
parent | 09a3d8f5c4a7f1e696b8b8075ef2ca8877714314 (diff) | |
parent | d9087e1b4499d5399da0d57a3fbd2d3a9c7c71c5 (diff) |
Merge pull request #32592 from Chaosus/fix_const_shader_crash
Prevent shader crash if function call been used for constant initialization
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/shader_language.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 30bd5884a2..25c12eafc5 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -4005,6 +4005,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui return ERR_PARSE_ERROR; } + if (node->is_const && n->type == Node::TYPE_OPERATOR && ((OperatorNode *)n)->op == OP_CALL) { + _set_error("Expected constant expression"); + return ERR_PARSE_ERROR; + } + if (var.type != n->get_datatype()) { _set_error("Invalid assignment of '" + get_datatype_name(n->get_datatype()) + "' to '" + get_datatype_name(var.type) + "'"); return ERR_PARSE_ERROR; @@ -4065,7 +4070,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui Node *n = _parse_and_reduce_expression(p_block, p_builtin_types); if (!n) return ERR_PARSE_ERROR; - + if (node->is_const && n->type == Node::TYPE_OPERATOR && ((OperatorNode *)n)->op == OP_CALL) { + _set_error("Expected constant expression after '='"); + return ERR_PARSE_ERROR; + } decl.initializer = n; if (var.type != n->get_datatype()) { |