From b48dd1bdafae18d8a14152795062c0e7e9ad9435 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Thu, 17 Jan 2019 23:15:20 +0100 Subject: [PATCH] C#: Fix crash due to missing gchandle ref null check --- modules/mono/csharp_script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 1b2ba58d22e..13f8385745e 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1189,7 +1189,7 @@ bool CSharpLanguage::refcount_decremented_instance_binding(Object *p_object) { return refcount == 0; Ref &gchandle = ((Map::Element *)data)->get().gchandle; - if (refcount == 1 && !gchandle->is_weak()) { // The managed side also holds a reference, hence 1 instead of 0 + if (refcount == 1 && gchandle.is_valid() && !gchandle->is_weak()) { // The managed side also holds a reference, hence 1 instead of 0 // If owner owner is no longer referenced by the unmanaged side, // the managed instance takes responsibility of deleting the owner when GCed.