summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam Scott <ascott.ca@gmail.com>2022-12-15 11:53:38 -0500
committerAdam Scott <ascott.ca@gmail.com>2022-12-15 12:29:01 -0500
commit3684fd249e3f79c7c59d03a3ddcfc92407e94ed6 (patch)
tree99638cbf75586a588db56c48cd0a7d4e199bfa85 /modules
parentd99ea32999b34d6997166991868065e9e402f522 (diff)
Fix `GDScript::_get_gdscript_from_variant()` crash
The crash would happen, theoretically, when getting the type of a invalid variant.
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript.cpp7
1 files changed, 1 insertions, 6 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 91f31174dd..258f1a80f7 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<GDScript>(obj);
}