From eaac00448ea2bb2068596b4cbb1b12c371363596 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Thu, 23 Apr 2015 20:43:39 +0300 Subject: [PATCH] [fix] crash while loading bad image --- SAMCache/SAMCache.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SAMCache/SAMCache.m b/SAMCache/SAMCache.m index c007286..bcd7560 100644 --- a/SAMCache/SAMCache.m +++ b/SAMCache/SAMCache.m @@ -284,9 +284,10 @@ - (UIImage *)imageForKey:(NSString *)key { // Load object from disk image = [UIImage imageWithContentsOfFile:path]; - - // Store in cache - [self.cache setObject:image forKey:key]; + if (image) { + // Store in cache + [self.cache setObject:image forKey:key]; + } return image; }