You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/04/26 06:56:40 UTC

[18/50] [abbrv] incubator-weex git commit: * [ios] protect crash when access nil address

* [ios] protect crash when access nil address


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/7bde63a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/7bde63a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/7bde63a1

Branch: refs/heads/dev
Commit: 7bde63a190376363b2cc13ef35b3daded0c930c2
Parents: fee493b
Author: acton393 <zh...@gmail.com>
Authored: Fri Apr 21 17:29:31 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Apr 21 17:29:31 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7bde63a1/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
index 2ebc098..b4a29e3 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
@@ -220,8 +220,11 @@ static css_node_t * rootNodeGetChild(void *context, int i)
 - (void)_recursivelyAddComponent:(NSDictionary *)componentData toSupercomponent:(WXComponent *)supercomponent atIndex:(NSInteger)index appendingInTree:(BOOL)appendingInTree
 {
     WXComponent *component = [self _buildComponentForData:componentData];
-    
-    index = (index == -1 ? supercomponent->_subcomponents.count : index);
+    if (!supercomponent.subcomponents) {
+        index = 0;
+    } else {
+        index = (index == -1 ? supercomponent->_subcomponents.count : index);
+    }
     
     [supercomponent _insertSubcomponent:component atIndex:index];
     // use _lazyCreateView to forbid component like cell's view creating