Merge pull request #70113 from adamscott/fix-crash-gdscript-from-variant

Fix `GDScript::_get_gdscript_from_variant()` crash
This commit is contained in:
Rémi Verschelde 2022-12-15 22:13:34 +01:00
commit 15631e24f7
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 1 additions and 6 deletions

View File

@ -1288,15 +1288,10 @@ String GDScript::_get_gdscript_reference_class_name(const GDScript *p_gdscript)
}
GDScript *GDScript::_get_gdscript_from_variant(const Variant &p_variant) {
Variant::Type type = p_variant.get_type();
if (type != Variant::Type::OBJECT)
return nullptr;
Object *obj = p_variant;
if (obj == nullptr) {
if (obj == nullptr || obj->get_instance_id().is_null()) {
return nullptr;
}
return Object::cast_to<GDScript>(obj);
}