Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDScript: Fix null deref when ensuring cached parsers #94697

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading