You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ji...@apache.org on 2019/08/16 03:09:07 UTC
[incubator-weex] branch master updated: [Android] Fix C++ Crash in
WeexCore::NotifyLayout. (#2831)
This is an automated email from the ASF dual-hosted git repository.
jianhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new f3c3c17 [Android] Fix C++ Crash in WeexCore::NotifyLayout. (#2831)
f3c3c17 is described below
commit f3c3c17a7cb9de6f6f286159c7771b14d2d535b4
Author: YorkShen <sh...@gmail.com>
AuthorDate: Fri Aug 16 11:09:01 2019 +0800
[Android] Fix C++ Crash in WeexCore::NotifyLayout. (#2831)
The return value of `jString2StrFast(env, instanceId)` could be `std::string(nullptr)`` if instanceId is `nullptr`, in which case the return value would cause crash.
```
#00 pc 0x4aaec libweexcore.so (_ZNSt6__ndk16__treeINS_12__value_typeINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPN8WeexCore14RenderPageBaseEEENS_19__map_value_compareIS7_SB_NS_4lessIS7_EELb1EEENS5_ISB_EEE13__lower_boundIS7_EENS_15__tree_iteratorISB_PNS_11__tree_nodeISB_PvEEiEERKT_SN_PNS_15__tree_end_nodeIPNS_16__tree_node_baseISL_EEEE+23)
#01 pc 0x4aa6b libweexcore.so (_ZNSt6__ndk16__treeINS_12__value_typeINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPN8WeexCore14RenderPageBaseEEENS_19__map_value_compareIS7_SB_NS_4lessIS7_EELb1EEENS5_ISB_EEE4findIS7_EENS_15__tree_iteratorISB_PNS_11__tree_nodeISB_PvEEiEERKT_+18)
#02 pc 0x4907b libweexcore.so (_ZN8WeexCore13RenderManager7GetPageERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE+6)
#03 pc 0x5d2d5 libweexcore.so (_ZN8WeexCore18CoreSideInPlatform12NotifyLayoutERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE+12)
```
---
weex_core/Source/android/wrap/wx_bridge.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/weex_core/Source/android/wrap/wx_bridge.cpp b/weex_core/Source/android/wrap/wx_bridge.cpp
index 53ec056..d0e7466 100755
--- a/weex_core/Source/android/wrap/wx_bridge.cpp
+++ b/weex_core/Source/android/wrap/wx_bridge.cpp
@@ -178,10 +178,13 @@ static jlongArray GetRenderFinishTime(JNIEnv* env, jobject jcaller,
// Notice that this method is invoked from main thread.
static jboolean NotifyLayout(JNIEnv* env, jobject jcaller, jstring instanceId) {
if (WeexCoreManager::Instance()->getPlatformBridge()) {
+ ScopedJStringUTF8 nativeString = ScopedJStringUTF8(env, instanceId);
+ const char* c_str_instance_id = nativeString.getChars();
+ std::string std_string_nstanceId = std::string(c_str_instance_id == nullptr ? "" : c_str_instance_id);
return WeexCoreManager::Instance()
->getPlatformBridge()
->core_side()
- ->NotifyLayout(jString2StrFast(env, instanceId));
+ ->NotifyLayout(std_string_nstanceId);
}
return false;
}