summaryrefslogtreecommitdiffstats
path: root/platform/android/plugin
diff options
context:
space:
mode:
authorshendo <steve.henderson@hendotech.com.au>2023-04-28 19:31:22 +1000
committershendo <steve.henderson@hendotech.com.au>2023-05-01 16:31:23 +1000
commit92ade92fce387f904f8d1bf4df2ab1307b5eca75 (patch)
tree3a03c490cd50f3787697159006f9cf8cb4ef8628 /platform/android/plugin
parent9f12e7b52d944281a39b7d3a33de6700c76cc23a (diff)
downloadredot-engine-92ade92fce387f904f8d1bf4df2ab1307b5eca75.tar.gz
[Android] Fix dynamic Variant params stack constructions in JNI callbacks
Emitting signals with params from Android plugins could crash due to object assignment with uninitialised mem. Instead, use 'memnew_placement' to construct into stack addresses. Make similar JNI callbacks consistent. Fixes #75754.
Diffstat (limited to 'platform/android/plugin')
-rw-r--r--platform/android/plugin/godot_plugin_jni.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/platform/android/plugin/godot_plugin_jni.cpp b/platform/android/plugin/godot_plugin_jni.cpp
index 4bb90cb971..843c015d49 100644
--- a/platform/android/plugin/godot_plugin_jni.cpp
+++ b/platform/android/plugin/godot_plugin_jni.cpp
@@ -120,7 +120,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_plugin_GodotPlugin_nativeEmitS
for (int i = 0; i < count; i++) {
jobject j_param = env->GetObjectArrayElement(j_signal_params, i);
- variant_params[i] = _jobject_to_variant(env, j_param);
+ ERR_FAIL_NULL(j_param);
+ memnew_placement(&variant_params[i], Variant(_jobject_to_variant(env, j_param)));
args[i] = &variant_params[i];
env->DeleteLocalRef(j_param);
}