From 95574c1b11da362c427d6331c74c672bb001844e Mon Sep 17 00:00:00 2001 From: DNKpp Date: Tue, 26 Jul 2022 00:41:57 +0200 Subject: [PATCH] fix: Object::cast_to checks provided object for nullptr --- include/godot_cpp/core/object.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index 6b1bed9d..df2ef25e 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -169,6 +169,9 @@ public: template T *Object::cast_to(Object *p_object) { + if (p_object == nullptr) { + return nullptr; + } GDNativeObjectPtr casted = internal::gdn_interface->object_cast_to(p_object->_owner, internal::gdn_interface->classdb_get_class_tag(T::get_class_static())); if (casted == nullptr) { return nullptr;