CB-10873 - Avoid crash due to usage of uninitialized variable when writing geolocation data to image destination - Properly handle 'CameraUsesGeolocation' option by properly setting geolocation data in EXIF header in all cases
This closes #205 Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/4202fff7 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/4202fff7 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/4202fff7 Branch: refs/heads/master Commit: 4202fff7ac361b72f6e37d375ff65b0c207a6d0d Parents: def399f Author: Omar Mefire <omef...@gmail.com> Authored: Wed Apr 13 12:14:46 2016 -0700 Committer: Omar Mefire <omef...@gmail.com> Committed: Wed Apr 13 15:49:51 2016 -0700 ---------------------------------------------------------------------- src/ios/CDVCamera.m | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/4202fff7/src/ios/CDVCamera.m ---------------------------------------------------------------------- diff --git a/src/ios/CDVCamera.m b/src/ios/CDVCamera.m index 6bb1936..42dd469 100644 --- a/src/ios/CDVCamera.m +++ b/src/ios/CDVCamera.m @@ -359,22 +359,23 @@ static NSString* toBase64(NSData* data) { data = UIImageJPEGRepresentation(image, 1.0); } else { data = UIImageJPEGRepresentation(image, [options.quality floatValue] / 100.0f); - if (options.usesGeolocation) { - NSDictionary* controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"]; - if (controllerMetadata) { - self.data = data; - self.metadata = [[NSMutableDictionary alloc] init]; - - NSMutableDictionary* EXIFDictionary = [[controllerMetadata objectForKey:(NSString*)kCGImagePropertyExifDictionary]mutableCopy]; - if (EXIFDictionary) { - [self.metadata setObject:EXIFDictionary forKey:(NSString*)kCGImagePropertyExifDictionary]; - } - - if (IsAtLeastiOSVersion(@"8.0")) { - [[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0]; - } - [[self locationManager] startUpdatingLocation]; + } + + if (options.usesGeolocation) { + NSDictionary* controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"]; + if (controllerMetadata) { + self.data = data; + self.metadata = [[NSMutableDictionary alloc] init]; + + NSMutableDictionary* EXIFDictionary = [[controllerMetadata objectForKey:(NSString*)kCGImagePropertyExifDictionary]mutableCopy]; + if (EXIFDictionary) { + [self.metadata setObject:EXIFDictionary forKey:(NSString*)kCGImagePropertyExifDictionary]; + } + + if (IsAtLeastiOSVersion(@"8.0")) { + [[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0]; } + [[self locationManager] startUpdatingLocation]; } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org