mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 19:15:05 +00:00
[Crashfix] Ensure that the image response is non-nil before caching it
Summary: If you try to create a cached response from a nil response the app will crash. Looking at the code that uses NSURLSession and NSURLCache, this fix looks correct to me. Fixes #1850 Closes https://github.com/facebook/react-native/pull/1852 Github Author: James Ide <ide@jameside.com>
This commit is contained in:
parent
66e32dc406
commit
3441847aa1
@ -90,9 +90,11 @@ CGRect RCTClipRect(CGSize, CGFloat, CGSize, CGFloat, UIViewContentMode);
|
||||
runBlocks(NO, data, error);
|
||||
}
|
||||
|
||||
RCTImageDownloader *strongSelf = weakSelf;
|
||||
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data userInfo:nil storagePolicy:NSURLCacheStorageAllowed];
|
||||
[strongSelf->_cache storeCachedResponse:cachedResponse forDataTask:task];
|
||||
if (response) {
|
||||
RCTImageDownloader *strongSelf = weakSelf;
|
||||
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data userInfo:nil storagePolicy:NSURLCacheStorageAllowed];
|
||||
[strongSelf->_cache storeCachedResponse:cachedResponse forDataTask:task];
|
||||
}
|
||||
task = nil;
|
||||
}];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user