From ee301bceb53c2f9aec84cb314eaec6c65bd9fcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Thu, 30 Apr 2020 10:23:30 +0200 Subject: [PATCH] Fix errors in Variant to RID conversion --- core/variant.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/variant.cpp b/core/variant.cpp index 592296d91b..13ff2bfbda 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1762,11 +1762,12 @@ Variant::operator RID() const { return _get_obj().ref.get_rid(); } else { #ifdef DEBUG_ENABLED - Object *obj = _get_obj().rc->get_ptr(); + Object *obj = likely(_get_obj().rc) ? _get_obj().rc->get_ptr() : NULL; if (unlikely(!obj)) { if (ScriptDebugger::get_singleton() && _get_obj().rc && !ObjectDB::get_instance(_get_obj().rc->instance_id)) { WARN_PRINT("Attempted get RID on a deleted object."); } + return RID(); } #else Object *obj = _get_obj().obj;