Merge pull request #55493 from V-Sekai/gdscript-crash

GDScript cache crashfix.
This commit is contained in:
Rémi Verschelde 2022-01-23 09:31:08 +01:00 committed by GitHub
commit 2f277994d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,6 +122,10 @@ Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptP
} }
if (singleton->parser_map.has(p_path)) { if (singleton->parser_map.has(p_path)) {
ref = Ref<GDScriptParserRef>(singleton->parser_map[p_path]); ref = Ref<GDScriptParserRef>(singleton->parser_map[p_path]);
if (ref.is_null()) {
r_error = ERR_INVALID_DATA;
return ref;
}
} else { } else {
if (!FileAccess::exists(p_path)) { if (!FileAccess::exists(p_path)) {
r_error = ERR_FILE_NOT_FOUND; r_error = ERR_FILE_NOT_FOUND;
@ -133,7 +137,6 @@ Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptP
ref->path = p_path; ref->path = p_path;
singleton->parser_map[p_path] = ref.ptr(); singleton->parser_map[p_path] = ref.ptr();
} }
r_error = ref->raise_status(p_status); r_error = ref->raise_status(p_status);
return ref; return ref;