Make get_jni_env safer.
GitOrigin-RevId: 15d1d788e9f2811e769554044992ae1d7db7fb9a
This commit is contained in:
parent
78b19d949f
commit
a67225d358
@ -79,7 +79,7 @@ void register_native_method(JNIEnv *env, jclass clazz, std::string name, std::st
|
||||
|
||||
std::unique_ptr<JNIEnv, JvmThreadDetacher> get_jni_env(JavaVM *java_vm, jint jni_version) {
|
||||
JNIEnv *env = nullptr;
|
||||
if (java_vm->GetEnv(reinterpret_cast<void **>(&env), jni_version) == JNI_EDETACHED) {
|
||||
if (java_vm->GetEnv(reinterpret_cast<void **>(&env), jni_version) == JNI_EDETACHED && env != nullptr) {
|
||||
#ifdef JDK1_2 // if not Android JNI
|
||||
auto p_env = reinterpret_cast<void **>(&env);
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user