diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2024-04-15 10:30:18 -0700 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuya@meta.com> | 2024-04-15 10:30:18 -0700 |
commit | f291a4ed3a64dd95bf8136f352e5d0554ada4a7c (patch) | |
tree | 5dd8a611fea937d1a372798a2e541cf2725f03cd /platform/android/api/jni_singleton.h | |
parent | b8fa48be040890f344a5178cf0fb9ea69c24f88e (diff) | |
download | redot-engine-f291a4ed3a64dd95bf8136f352e5d0554ada4a7c.tar.gz |
Fix leakage of JNI object references
Fixes https://github.com/godotengine/godot/issues/87548
Diffstat (limited to 'platform/android/api/jni_singleton.h')
-rw-r--r-- | platform/android/api/jni_singleton.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h index a2d1c08168..5b30c392e7 100644 --- a/platform/android/api/jni_singleton.h +++ b/platform/android/api/jni_singleton.h @@ -241,6 +241,17 @@ public: instance = nullptr; #endif } + + ~JNISingleton() { +#ifdef ANDROID_ENABLED + if (instance) { + JNIEnv *env = get_jni_env(); + ERR_FAIL_NULL(env); + + env->DeleteGlobalRef(instance); + } +#endif + } }; #endif // JNI_SINGLETON_H |