From c2f59de212546e2005e4cbdde9515599cdaa3b78 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 26 Jan 2019 15:41:26 -0300 Subject: Warn of invalid pointer when converting object to RID, closes #19023 --- core/variant.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'core/variant.cpp') diff --git a/core/variant.cpp b/core/variant.cpp index 8b2051add7..56b272cccf 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1731,6 +1731,14 @@ Variant::operator RID() const { else if (type == OBJECT && !_get_obj().ref.is_null()) { return _get_obj().ref.get_rid(); } else if (type == OBJECT && _get_obj().obj) { +#ifdef DEBUG_ENABLED + if (ScriptDebugger::get_singleton()) { + if (!ObjectDB::instance_validate(_get_obj().obj)) { + ERR_EXPLAIN("Invalid pointer (object was deleted)"); + ERR_FAIL_V(RID()); + }; + }; +#endif Variant::CallError ce; Variant ret = _get_obj().obj->call(CoreStringNames::get_singleton()->get_rid, NULL, 0, ce); if (ce.error == Variant::CallError::CALL_OK && ret.get_type() == Variant::_RID) { -- cgit v1.2.3