Skip to content

Commit

Permalink
Merge pull request #50895 from Chaosus/fix_shader_crash
Browse files Browse the repository at this point in the history
Fix editor crash if passing index as variable to function parameter
  • Loading branch information
akien-mga authored Jul 26, 2021
2 parents 8f6c16e + c082982 commit fef27e9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions servers/rendering/shader_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4796,10 +4796,12 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
String member_struct_name;

if (expr->get_array_size() > 0) {
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
if (index_constant >= (uint32_t)expr->get_array_size()) {
_set_error(vformat("Index [%s] out of range [%s..%s]", index_constant, 0, expr->get_array_size() - 1));
return nullptr;
if (index->type == Node::TYPE_CONSTANT) {
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
if (index_constant >= (uint32_t)expr->get_array_size()) {
_set_error(vformat("Index [%s] out of range [%s..%s]", index_constant, 0, expr->get_array_size() - 1));
return nullptr;
}
}
member_type = expr->get_datatype();
if (member_type == TYPE_STRUCT) {
Expand Down

0 comments on commit fef27e9

Please sign in to comment.