Skip to content

Commit

Permalink
Fix editor crash when shader has incorrect global array declaratio
Browse files Browse the repository at this point in the history
  • Loading branch information
jsjtxietian committed Apr 17, 2024
1 parent d007340 commit 0516945
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion servers/rendering/shader_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,11 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
} else {
code += "";
}
code += _dump_node_code(cnode->array_declarations[0].initializer[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
if (cnode->array_declarations[0].initializer.size() < i + 1) {
code += "";
} else {
code += _dump_node_code(cnode->array_declarations[0].initializer[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning);
}
}
code += ")";
}
Expand Down
3 changes: 3 additions & 0 deletions servers/rendering/shader_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9361,6 +9361,9 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
_set_error(RTR("Array size mismatch."));
return ERR_PARSE_ERROR;
}
} else {
_set_expected_error("(,{");
return ERR_PARSE_ERROR;
}

array_size = constant.array_size;
Expand Down

0 comments on commit 0516945

Please sign in to comment.