Skip to content

Commit

Permalink
If object is nil, do not try and 'handle' it.
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmoon committed Apr 13, 2016
1 parent 5007fd2 commit f15ca03
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Pod/Classes/PINRemoteImageManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@ - (BOOL)handleCacheObject:(PINCache *)cache
outImage:(PINImage **)outImage
outAnimatedImage:(FLAnimatedImage **)outAnimatedImage
{
NSAssert(object != nil, @"Object should not be nil.");
if (object == nil) {
return NO;
}

BOOL ignoreGIF = (PINRemoteImageManagerDownloadOptionsIgnoreGIFs & options) != 0;
FLAnimatedImage *animatedImage = nil;
PINImage *image = nil;
Expand Down Expand Up @@ -1119,7 +1124,10 @@ - (void)imageFromCacheWithCacheKey:(NSString *)cacheKey
PINImage *image;
FLAnimatedImage *animatedImage;
NSError *error = nil;
if ([strongSelf handleCacheObject:strongSelf.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
if (object == nil) {
image = nil;
animatedImage = nil;
} else if ([strongSelf handleCacheObject:strongSelf.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
error = [NSError errorWithDomain:PINRemoteImageManagerErrorDomain
code:PINRemoteImageManagerErrorInvalidItemInCache
userInfo:nil];
Expand All @@ -1144,7 +1152,10 @@ - (PINRemoteImageManagerResult *)synchronousImageFromCacheWithCacheKey:(NSString
PINImage *image;
FLAnimatedImage *animatedImage;
NSError *error = nil;
if ([self handleCacheObject:self.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
if (object == nil) {
image = nil;
animatedImage = nil;
} else if ([self handleCacheObject:self.cache object:object key:cacheKey options:options outImage:&image outAnimatedImage:&animatedImage] == NO) {
error = [NSError errorWithDomain:PINRemoteImageManagerErrorDomain
code:PINRemoteImageManagerErrorInvalidItemInCache
userInfo:nil];
Expand Down

0 comments on commit f15ca03

Please sign in to comment.