From a67225d358f1a48b7b1ef0f33ee38d0cabb8e7bb Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 11 Oct 2020 14:44:42 +0300 Subject: [PATCH] Make get_jni_env safer. GitOrigin-RevId: 15d1d788e9f2811e769554044992ae1d7db7fb9a --- td/tl/tl_jni_object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/td/tl/tl_jni_object.cpp b/td/tl/tl_jni_object.cpp index 640635c32..169e0dd3b 100644 --- a/td/tl/tl_jni_object.cpp +++ b/td/tl/tl_jni_object.cpp @@ -79,7 +79,7 @@ void register_native_method(JNIEnv *env, jclass clazz, std::string name, std::st std::unique_ptr get_jni_env(JavaVM *java_vm, jint jni_version) { JNIEnv *env = nullptr; - if (java_vm->GetEnv(reinterpret_cast(&env), jni_version) == JNI_EDETACHED) { + if (java_vm->GetEnv(reinterpret_cast(&env), jni_version) == JNI_EDETACHED && env != nullptr) { #ifdef JDK1_2 // if not Android JNI auto p_env = reinterpret_cast(&env); #else