Permalink
Browse files

Merge pull request #819 from n13/master

guarding against image source == NULL
  • Loading branch information...
2 parents b88a552 + 9faee53 commit 681a7c4222bc816a15f955377dbfe5c492d365cc @bpoplauschi bpoplauschi committed Jul 18, 2014
Showing with 15 additions and 13 deletions.
  1. +15 −13 SDWebImage/UIImage+MultiFormat.m
@@ -47,20 +47,22 @@ + (UIImage *)sd_imageWithData:(NSData *)data {
+(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData {
UIImageOrientation result = UIImageOrientationUp;
CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL);
- CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
- if (properties) {
- CFTypeRef val;
- int exifOrientation;
- val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);
- if (val) {
- CFNumberGetValue(val, kCFNumberIntType, &exifOrientation);
- result = [self sd_exifOrientationToiOSOrientation:exifOrientation];
- } // else - if it's not set it remains at up
- CFRelease((CFTypeRef) properties);
- } else {
- //NSLog(@"NO PROPERTIES, FAIL");
+ if (imageSource) {
+ CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL);
+ if (properties) {
+ CFTypeRef val;
+ int exifOrientation;
+ val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation);
+ if (val) {
+ CFNumberGetValue(val, kCFNumberIntType, &exifOrientation);
+ result = [self sd_exifOrientationToiOSOrientation:exifOrientation];
+ } // else - if it's not set it remains at up
+ CFRelease((CFTypeRef) properties);
+ } else {
+ //NSLog(@"NO PROPERTIES, FAIL");
+ }
+ CFRelease(imageSource);
}
- CFRelease(imageSource);
return result;
}

0 comments on commit 681a7c4

Please sign in to comment.