You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Fix GDScript::_get_gdscript_from_variant() crash
The crash would happen, theoretically, when getting the type of a invalid variant.
This commit is contained in:
@@ -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) {
|
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;
|
Object *obj = p_variant;
|
||||||
if (obj == nullptr) {
|
if (obj == nullptr || obj->get_instance_id().is_null()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object::cast_to<GDScript>(obj);
|
return Object::cast_to<GDScript>(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user