aboutsummaryrefslogtreecommitdiffhomepage
path: root/example
diff options
context:
space:
mode:
authorGravatar geoffcoward <geoffcoward@gmail.com>2016-05-11 17:45:26 -0700
committerGravatar HoĆ  V. DINH <dinh.viet.hoa@gmail.com>2016-05-11 17:45:26 -0700
commit459d616efb48ecb2c157fecfb88e92a876db893d (patch)
tree632c8bce176db121fd83e956c8c0a22cd6e378f4 /example
parenta9f8d0676ffa05d13f9968af087d899cbea06e8a (diff)
Prevent demo crash in _convertToJPEGData when image data cannot be converted (#1420)
* Prevent demo crash in _convertToJPEGData when image data cannot be converted.
Diffstat (limited to 'example')
-rwxr-xr-xexample/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm35
1 files changed, 20 insertions, 15 deletions
diff --git a/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm b/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm
index db8a1122..714ff2de 100755
--- a/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm
+++ b/example/ios/iOS UI Test/iOS UI Test/MCTMsgViewController.mm
@@ -254,22 +254,27 @@ typedef void (^DownloadCallback)(NSError * error);
[info setObject:(id) [NSNumber numberWithFloat:(float) IMAGE_PREVIEW_WIDTH] forKey:(__bridge id) kCGImageSourceThumbnailMaxPixelSize];
thumbnail = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, (__bridge CFDictionaryRef) info);
- CGImageDestinationRef destination;
- NSMutableData * destData = [NSMutableData data];
-
- destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef) destData,
- (CFStringRef) @"public.jpeg",
- 1, NULL);
+ if (thumbnail != nil) {
+
+ CGImageDestinationRef destination;
+ NSMutableData * destData = [NSMutableData data];
+ destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef) destData,
+ (CFStringRef) @"public.jpeg",
+ 1, NULL);
+
+ CGImageDestinationAddImage(destination, thumbnail, NULL);
+ CGImageDestinationFinalize(destination);
+
+ CFRelease(destination);
+
+ CFRelease(thumbnail);
+ CFRelease(imageSource);
+
+ return destData;
+ } else {
+ return nil;
+ }
- CGImageDestinationAddImage(destination, thumbnail, NULL);
- CGImageDestinationFinalize(destination);
-
- CFRelease(destination);
-
- CFRelease(thumbnail);
- CFRelease(imageSource);
-
- return destData;
}
@end