Merge pull request #43176 from mateosss/crash-uninit-const

Fix crash by adding nullcheck for uninitialized constants
This commit is contained in:
Rémi Verschelde 2021-01-11 14:00:54 +01:00 committed by GitHub
commit 51992250e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1163,6 +1163,7 @@ void GDScriptAnalyzer::resolve_variable(GDScriptParser::VariableNode *p_variable
void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant) {
GDScriptParser::DataType type;
if (p_constant->initializer != nullptr) {
reduce_expression(p_constant->initializer);
if (p_constant->initializer->type == GDScriptParser::Node::ARRAY) {
const_fold_array(static_cast<GDScriptParser::ArrayNode *>(p_constant->initializer));
@ -1181,6 +1182,7 @@ void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant
parser->push_warning(p_constant->initializer, GDScriptWarning::VOID_ASSIGNMENT, static_cast<GDScriptParser::CallNode *>(p_constant->initializer)->function_name);
}
#endif
}
if (p_constant->datatype_specifier != nullptr) {
GDScriptParser::DataType explicit_type = resolve_datatype(p_constant->datatype_specifier);