Skip to content

Commit f15ca03

Browse files
committed
If object is nil, do not try and 'handle' it.
1 parent 5007fd2 commit f15ca03

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Pod/Classes/PINRemoteImageManager.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,11 @@ - (BOOL)handleCacheObject:(PINCache *)cache
790790
outImage:(PINImage **)outImage
791791
outAnimatedImage:(FLAnimatedImage **)outAnimatedImage
792792
{
793+
NSAssert(object != nil, @"Object should not be nil.");
794+
if (object == nil) {
795+
return NO;
796+
}
797+
793798
BOOL ignoreGIF = (PINRemoteImageManagerDownloadOptionsIgnoreGIFs & options) != 0;
794799
FLAnimatedImage *animatedImage = nil;
795800
PINImage *image = nil;
@@ -1119,7 +1124,10 @@ - (void)imageFromCacheWithCacheKey:(NSString *)cacheKey
11191124
PINImage *image;
11201125
FLAnimatedImage *animatedImage;
11211126
NSError *error = nil;
1122-
if ([strongSelf handleCacheObject:strongSelf.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
1127+
if (object == nil) {
1128+
image = nil;
1129+
animatedImage = nil;
1130+
} else if ([strongSelf handleCacheObject:strongSelf.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
11231131
error = [NSError errorWithDomain:PINRemoteImageManagerErrorDomain
11241132
code:PINRemoteImageManagerErrorInvalidItemInCache
11251133
userInfo:nil];
@@ -1144,7 +1152,10 @@ - (PINRemoteImageManagerResult *)synchronousImageFromCacheWithCacheKey:(NSString
11441152
PINImage *image;
11451153
FLAnimatedImage *animatedImage;
11461154
NSError *error = nil;
1147-
if ([self handleCacheObject:self.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
1155+
if (object == nil) {
1156+
image = nil;
1157+
animatedImage = nil;
1158+
} else if ([self handleCacheObject:self.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
11481159
error = [NSError errorWithDomain:PINRemoteImageManagerErrorDomain
11491160
code:PINRemoteImageManagerErrorInvalidItemInCache
11501161
userInfo:nil];

0 commit comments

Comments
 (0)