From 0757241822ea079faffe82b6a9e30a6f03cc11e9 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sat, 16 Jul 2022 19:43:48 +0800 Subject: [PATCH] Fix the clang analyze issue --- SDWebImage/Core/SDWebImageManager.m | 7 +------ SDWebImage/Core/UIImage+Transform.m | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/SDWebImage/Core/SDWebImageManager.m b/SDWebImage/Core/SDWebImageManager.m index 73e9c5ec..44f5838c 100644 --- a/SDWebImage/Core/SDWebImageManager.m +++ b/SDWebImage/Core/SDWebImageManager.m @@ -552,11 +552,6 @@ static id _defaultImageLoader; cacheType:(SDImageCacheType)cacheType finished:(BOOL)finished completed:(nullable SDInternalCompletionBlock)completedBlock { - // the target image store cache type - SDImageCacheType storeCacheType = SDImageCacheTypeAll; - if (context[SDWebImageContextStoreCacheType]) { - storeCacheType = [context[SDWebImageContextStoreCacheType] integerValue]; - } id transformer = context[SDWebImageContextImageTransformer]; if (![transformer conformsToProtocol:@protocol(SDImageTransformer)]) { transformer = nil; @@ -661,7 +656,7 @@ static id _defaultImageLoader; BOOL shouldThumbnailImage = context[SDWebImageContextImageThumbnailPixelSize] != nil || image.sd_decodeOptions[SDImageCoderDecodeThumbnailPixelSize] != nil; // Store the transformed/thumbnail image into the cache - if (transformed || shouldThumbnailImage) { + if (image && (transformed || shouldThumbnailImage)) { NSData *cacheData; // pass nil if the image was transformed/thumbnailed, so we can recalculate the data from the image if (cacheSerializer && (storeCacheType == SDImageCacheTypeDisk || storeCacheType == SDImageCacheTypeAll)) { diff --git a/SDWebImage/Core/UIImage+Transform.m b/SDWebImage/Core/UIImage+Transform.m index b8a16edd..2cd8a6f9 100644 --- a/SDWebImage/Core/UIImage+Transform.m +++ b/SDWebImage/Core/UIImage+Transform.m @@ -576,6 +576,8 @@ static inline CGImageRef _Nullable SDCreateCGImageFromCIImage(CIImage * _Nonnull return SDGetColorFromRGBA(pixel, bitmapInfo); } else { NSLog(@"Unsupported components: %zu", components); + CFRelease(data); + CGImageRelease(imageRef); return nil; } }