From 03148e060366f17478cf370ae43d3dde74324473 Mon Sep 17 00:00:00 2001 From: ilikethese Date: Mon, 22 Jan 2024 15:14:08 +0800 Subject: [PATCH] fix(vfs): OnJniDelegateInvokeSync call after OnDestroyVfs --- .../main/cpp/src/handler/jni_delegate_handler.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/vfs/android/src/main/cpp/src/handler/jni_delegate_handler.cc b/modules/vfs/android/src/main/cpp/src/handler/jni_delegate_handler.cc index f3b54652ad1..4521d4f22ac 100644 --- a/modules/vfs/android/src/main/cpp/src/handler/jni_delegate_handler.cc +++ b/modules/vfs/android/src/main/cpp/src/handler/jni_delegate_handler.cc @@ -124,7 +124,9 @@ std::shared_ptr GetUriLoader(jint j_id) { bool flag = hippy::global_data_holder.Find( footstone::checked_numeric_cast(j_id), loader_object); - FOOTSTONE_CHECK(flag); + if (!flag) { + return nullptr; + } return std::any_cast>(loader_object); } @@ -252,6 +254,10 @@ void OnJniDelegateInvokeAsync(JNIEnv* j_env, __unused jobject j_object, jint j_i JNIEnvironment::ClearJEnvException(j_env); }; auto loader = GetUriLoader(j_id); + if (loader == nullptr) { + FOOTSTONE_LOG(ERROR) << "uri loader is null, uri loader id " << j_id; + return; + } loader->RequestUntrustedContent(uri, req_meta, cb); } @@ -265,6 +271,11 @@ void OnJniDelegateInvokeSync(JNIEnv* j_env, __unused jobject j_object, jint j_id UriLoader::bytes content; req_meta[kCallFromKey] = kCallFromJavaValue; auto loader = GetUriLoader(j_id); + if (loader == nullptr) { + FOOTSTONE_LOG(ERROR) << "uri loader is null, uri loader id " << j_id; + JNIEnvironment::ClearJEnvException(j_env); + return; + } loader->RequestUntrustedContent(uri, req_meta, code, rsp_meta, content); resource_holder->SetRspMeta(j_env, rsp_meta); resource_holder->SetContent(j_env, content);