Prevent array out of bound access
Summary:
Even so the problem of #236 has been fixed via ced779b
there is still a case where you have a out of bound array access of undefined behaviour. This PR prevents the out of bound access of the underlying c array. The out of bound access happens if you already have 4 subViews and add another one. Then you will access CSSNodeGetChild with 4 which points into uninitialized memory.
Closes https://github.com/facebook/css-layout/pull/237
Reviewed By: dshahidehpour
Differential Revision: D4107743
Pulled By: emilsjolander
fbshipit-source-id: 0f21397f3a77308369acfea7327733f74eb72e00
This commit is contained in:
committed by
Facebook Github Bot
parent
ced779b259
commit
af5e6771d7
@@ -250,7 +250,7 @@ static void _attachNodesRecursive(UIView *view) {
|
||||
// Add any children which were added since the last call to css_applyLayout
|
||||
for (NSUInteger i = 0; i < view.subviews.count; i++) {
|
||||
CSSNodeRef childNode = [view.subviews[i] cssNode];
|
||||
if (CSSNodeGetChild(node, i) != childNode) {
|
||||
if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) {
|
||||
CSSNodeInsertChild(node, childNode, i);
|
||||
}
|
||||
_attachNodesRecursive(view.subviews[i]);
|
||||
|
Reference in New Issue
Block a user