From 3684fd249e3f79c7c59d03a3ddcfc92407e94ed6 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Thu, 15 Dec 2022 11:53:38 -0500 Subject: [PATCH] Fix `GDScript::_get_gdscript_from_variant()` crash The crash would happen, theoretically, when getting the type of a invalid variant. --- modules/gdscript/gdscript.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 91f31174dd1..258f1a80f78 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -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(obj); }