diff options
author | Ignacio Roldán Etcheverry <neikeq@users.noreply.github.com> | 2021-08-24 06:09:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-24 06:09:43 +0200 |
commit | e95fa21b455a5e2c512fe6e054f86df1f01e5bd3 (patch) | |
tree | 7aa2305083aec79c6f39d139ceeb1abbe014bfa4 /modules/mono/mono_gd | |
parent | 13bd020a23008cd4e51be21865c620e12e3b3ded (diff) | |
parent | be4671534caa1e91c42a29732c15572879cac047 (diff) |
Merge pull request #47295 from omegachysis/script-bind-mutex
Fix race condition on `script_binding` in C#
Diffstat (limited to 'modules/mono/mono_gd')
-rw-r--r-- | modules/mono/mono_gd/gd_mono_internals.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index 60047545c4..cf76c23926 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -91,7 +91,11 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { // The object was just created, no script instance binding should have been attached CRASH_COND(CSharpLanguage::has_instance_binding(unmanaged)); - void *data = (void *)CSharpLanguage::get_singleton()->insert_script_binding(unmanaged, script_binding); + void *data; + { + MutexLock lock(CSharpLanguage::get_singleton()->get_language_bind_mutex()); + data = (void *)CSharpLanguage::get_singleton()->insert_script_binding(unmanaged, script_binding); + } // Should be thread safe because the object was just created and nothing else should be referencing it CSharpLanguage::set_instance_binding(unmanaged, data); |