Merge pull request #3052 from dreampiggy/fix_imageio_copy_mutable_dictionary_crash

Try to copy the local NSMutableDictionary before calling CGImageSourceCreateImageAtIndex, try to solve the rare crash inside ImageIO call stack.
This commit is contained in:
DreamPiggy 2020-07-16 20:14:53 +08:00 committed by GitHub
commit 5a34f2d468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -110,7 +110,7 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
+ (NSUInteger)imageLoopCountWithSource:(CGImageSourceRef)source {
NSUInteger loopCount = self.defaultLoopCount;
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, nil);
NSDictionary *imageProperties = (__bridge_transfer NSDictionary *)CGImageSourceCopyProperties(source, NULL);
NSDictionary *containerProperties = imageProperties[self.dictionaryProperty];
if (containerProperties) {
NSNumber *containerLoopCount = containerProperties[self.loopCountProperty];
@ -199,7 +199,7 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
NSUInteger rasterizationDPI = maxPixelSize * DPIPerPixel;
decodingOptions[kSDCGImageSourceRasterizationDPI] = @(rasterizationDPI);
}
imageRef = CGImageSourceCreateImageAtIndex(source, index, (__bridge CFDictionaryRef)decodingOptions);
imageRef = CGImageSourceCreateImageAtIndex(source, index, (__bridge CFDictionaryRef)[decodingOptions copy]);
} else {
decodingOptions[(__bridge NSString *)kCGImageSourceCreateThumbnailWithTransform] = @(preserveAspectRatio);
CGFloat maxPixelSize;
@ -216,7 +216,7 @@ static NSString * kSDCGImageDestinationRequestedFileSize = @"kCGImageDestination
}
decodingOptions[(__bridge NSString *)kCGImageSourceThumbnailMaxPixelSize] = @(maxPixelSize);
decodingOptions[(__bridge NSString *)kCGImageSourceCreateThumbnailFromImageAlways] = @(YES);
imageRef = CGImageSourceCreateThumbnailAtIndex(source, index, (__bridge CFDictionaryRef)decodingOptions);
imageRef = CGImageSourceCreateThumbnailAtIndex(source, index, (__bridge CFDictionaryRef)[decodingOptions copy]);
}
if (!imageRef) {
return nil;