From 6697e380d939bddc185649e22047916197deb658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Mon, 27 Sep 2021 19:46:49 +0200 Subject: [PATCH] Fix check for freed object during cast --- modules/gdscript/gdscript_function.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index d4542949da..05a4a53e04 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -846,7 +846,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a *dst = Variant::construct(to_type, (const Variant **)&src, 1, err); #ifdef DEBUG_ENABLED - if (src->get_type() == Variant::OBJECT && !src->is_ref() && ObjectDB::get_instance(src->get_object_instance_id()) == nullptr) { + if (src->is_invalid_object()) { err_text = "Trying to cast a deleted object."; OPCODE_BREAK; } @@ -870,7 +870,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a GD_ERR_BREAK(!nc); #ifdef DEBUG_ENABLED - if (src->get_type() == Variant::OBJECT && !src->is_ref() && ObjectDB::get_instance(src->get_object_instance_id()) == nullptr) { + if (src->is_invalid_object()) { err_text = "Trying to cast a deleted object."; OPCODE_BREAK; } @@ -902,7 +902,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a GD_ERR_BREAK(!base_type); #ifdef DEBUG_ENABLED - if (src->get_type() == Variant::OBJECT && !src->is_ref() && ObjectDB::get_instance(src->get_object_instance_id()) == nullptr) { + if (src->is_invalid_object()) { err_text = "Trying to cast a deleted object."; OPCODE_BREAK; }