Skip to content

Commit

Permalink
GDScript: Fix null deref when ensuring cached parsers
Browse files Browse the repository at this point in the history
Also move the error message to where it's relevant.
  • Loading branch information
vnen committed Jul 24, 2024
1 parent 91eb688 commit eeed8e0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions modules/gdscript/gdscript_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c

if (!parser->has_class(p_class)) {
if (parser_ref.is_null()) {
// Error already pushed.
push_error(vformat(R"(Could not find script "%s".)", p_class->get_datatype().script_path), p_source);
return ERR_PARSE_ERROR;
}

Expand Down Expand Up @@ -912,7 +912,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,

if (!parser->has_class(p_class)) {
if (parser_ref.is_null()) {
// Error already pushed.
push_error(vformat(R"(Could not find script "%s" (While resolving "%s").)", p_class->get_datatype().script_path, member.get_name()), p_source);
return;
}

Expand Down Expand Up @@ -1186,7 +1186,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas

if (!parser->has_class(p_class)) {
if (parser_ref.is_null()) {
// Error already pushed.
push_error(vformat(R"(Could not find script "%s".)", p_class->get_datatype().script_path), p_source);
return;
}

Expand Down Expand Up @@ -1275,7 +1275,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co

if (!parser->has_class(p_class)) {
if (parser_ref.is_null()) {
// Error already pushed.
push_error(vformat(R"(Could not find script "%s".)", p_class->get_datatype().script_path), p_source);
return;
}

Expand Down Expand Up @@ -3702,13 +3702,11 @@ Ref<GDScriptParserRef> GDScriptAnalyzer::ensure_cached_parser_for_class(const GD

dependant_parser_ref = Ref<GDScriptParserRef>();
dependant_parser = nullptr;
p_from_class = p_from_class->base_type.class_type;
if (p_from_class != nullptr) {
p_from_class = p_from_class->base_type.class_type;
}
} while (p_from_class != nullptr);

if (parser_ref.is_null()) {
push_error(vformat(R"(Parser bug: Could not find external parser. (%s))", p_context), p_source);
}

return parser_ref;
}

Expand Down

0 comments on commit eeed8e0

Please sign in to comment.