Update SDImageCache.m

Little logic check for nil value
This commit is contained in:
DreamPiggy 2022-06-12 17:10:23 +08:00 committed by GitHub
parent 754de4d7c8
commit a66972bdc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -195,11 +195,9 @@ static NSString * _defaultDiskCacheDirectory;
return;
}
// if memory cache is enabled
if (toMemory && self.config.shouldCacheImagesInMemory) {
if (image) {
NSUInteger cost = image.sd_memoryCost;
[self.memoryCache setObject:image forKey:key cost:cost];
}
if (image && toMemory && self.config.shouldCacheImagesInMemory) {
NSUInteger cost = image.sd_memoryCost;
[self.memoryCache setObject:image forKey:key cost:cost];
}
if (!toDisk) {
@ -242,7 +240,7 @@ static NSString * _defaultDiskCacheDirectory;
}
- (void)_archivedDataWithImage:(UIImage *)image forKey:(NSString *)key {
if (!image) {
if (!image || !key) {
return;
}
// Check extended data