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:
commit
5a34f2d468
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue