diff --git a/core/object/object.h b/core/object/object.h index f97691841fd..cb1495296dd 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -798,12 +798,12 @@ public: template static T *cast_to(Object *p_object) { - return dynamic_cast(p_object); + return p_object ? dynamic_cast(p_object) : nullptr; } template static const T *cast_to(const Object *p_object) { - return dynamic_cast(p_object); + return p_object ? dynamic_cast(p_object) : nullptr; } enum {