From bb84c37dcefe5f31fb6735cbcbbdc4051e3c08c7 Mon Sep 17 00:00:00 2001 From: Dustin Shahidehpour Date: Mon, 31 Oct 2016 12:41:09 -0700 Subject: [PATCH] Prevent crash when accessing child count, but child list is NULL. Reviewed By: emilsjolander Differential Revision: D4104093 fbshipit-source-id: cd7b09818759aa76415b97e241f1a6746a2bc50c --- React/CSSLayout/CSSNodeList.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/React/CSSLayout/CSSNodeList.c b/React/CSSLayout/CSSNodeList.c index c4b8f3c16..d48cf4b35 100644 --- a/React/CSSLayout/CSSNodeList.c +++ b/React/CSSLayout/CSSNodeList.c @@ -92,5 +92,9 @@ CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node) { } CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index) { - return list->items[index]; + if (CSSNodeListCount(list) > 0) { + return list->items[index]; + } + + return NULL; }