summaryrefslogtreecommitdiffstats
path: root/modules/mono/csharp_script.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-01-24 21:51:57 +0100
committerGitHub <noreply@github.com>2020-01-24 21:51:57 +0100
commitc96f08dc8620491954960a1af6a852dcf2c02f09 (patch)
treee7d47ea3dfe34f17c10c0977b839e5c955dc1b8b /modules/mono/csharp_script.cpp
parent75ab07546b6c6bd97153fda3abd5fbececd6fd96 (diff)
parent966a1261866142001d6f5c447c4a665da870b518 (diff)
downloadredot-engine-c96f08dc8620491954960a1af6a852dcf2c02f09.tar.gz
Merge pull request #35527 from neikeq/issue-35259
Mono/C#: Fix _update_exports possible crash with Reference types
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r--modules/mono/csharp_script.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 3d868b0839..9e19e5f8c4 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2425,6 +2425,9 @@ bool CSharpScript::_update_exports() {
top = top->get_parent_class();
}
+ // Need to check this here, before disposal
+ bool base_ref = Object::cast_to<Reference>(tmp_native) != NULL;
+
// Dispose the temporary managed instance
MonoException *exc = NULL;
@@ -2438,7 +2441,7 @@ bool CSharpScript::_update_exports() {
MonoGCHandle::free_handle(tmp_pinned_gchandle);
tmp_object = NULL;
- if (tmp_native && !Object::cast_to<Reference>(tmp_native)) {
+ if (tmp_native && !base_ref) {
Node *node = Object::cast_to<Node>(tmp_native);
if (node && node->is_inside_tree()) {
ERR_PRINTS("Temporary instance was added to the scene tree.");