Merge pull request #50895 from Chaosus/fix_shader_crash
Fix editor crash if passing index as variable to function parameter
This commit is contained in:
commit
fef27e9b5b
|
@ -4796,11 +4796,13 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
||||||
String member_struct_name;
|
String member_struct_name;
|
||||||
|
|
||||||
if (expr->get_array_size() > 0) {
|
if (expr->get_array_size() > 0) {
|
||||||
|
if (index->type == Node::TYPE_CONSTANT) {
|
||||||
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
|
uint32_t index_constant = static_cast<ConstantNode *>(index)->values[0].uint;
|
||||||
if (index_constant >= (uint32_t)expr->get_array_size()) {
|
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));
|
_set_error(vformat("Index [%s] out of range [%s..%s]", index_constant, 0, expr->get_array_size() - 1));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
member_type = expr->get_datatype();
|
member_type = expr->get_datatype();
|
||||||
if (member_type == TYPE_STRUCT) {
|
if (member_type == TYPE_STRUCT) {
|
||||||
member_struct_name = expr->get_datatype_name();
|
member_struct_name = expr->get_datatype_name();
|
||||||
|
|
Loading…
Reference in New Issue