From ed1ee9bc0f3ec051ce0a10e030c532953ce7710c Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Mon, 9 May 2016 08:17:57 -0700 Subject: [PATCH] Fixed crash due to inserting a nil object into an array Summary: Fixed a crash where making a network request with unrecognized/unsupported scheme would crash by attempting to insert a nil RCTNetworkTask into an array. Reviewed By: javache Differential Revision: D3275810 fb-gh-sync-id: be208c6bf87d882209901b850dcc25da4ba79a08 fbshipit-source-id: be208c6bf87d882209901b850dcc25da4ba79a08 --- Libraries/Image/RCTImageLoader.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Libraries/Image/RCTImageLoader.m b/Libraries/Image/RCTImageLoader.m index 8349a2e2b..75d1292e4 100644 --- a/Libraries/Image/RCTImageLoader.m +++ b/Libraries/Image/RCTImageLoader.m @@ -425,10 +425,12 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, if (!_pendingTasks) { _pendingTasks = [NSMutableArray new]; } - [_pendingTasks addObject:task]; - if (MAX(_activeTasks, _scheduledDecodes) < _maxConcurrentLoadingTasks) { - [task start]; - _activeTasks++; + if (task) { + [_pendingTasks addObject:task]; + if (MAX(_activeTasks, _scheduledDecodes) < _maxConcurrentLoadingTasks) { + [task start]; + _activeTasks++; + } } cancelLoad = ^{