- 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
This commit is contained in:
Omar Mefire
2016-04-13 12:14:46 -07:00
parent def399fe51
commit 4202fff7ac
+14 -13
View File
@@ -359,22 +359,23 @@ static NSString* toBase64(NSData* data) {
data = UIImageJPEGRepresentation(image, 1.0); data = UIImageJPEGRepresentation(image, 1.0);
} else { } else {
data = UIImageJPEGRepresentation(image, [options.quality floatValue] / 100.0f); 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 (options.usesGeolocation) {
if (EXIFDictionary) { NSDictionary* controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
[self.metadata setObject:EXIFDictionary forKey:(NSString*)kCGImagePropertyExifDictionary]; if (controllerMetadata) {
} self.data = data;
self.metadata = [[NSMutableDictionary alloc] init];
if (IsAtLeastiOSVersion(@"8.0")) { NSMutableDictionary* EXIFDictionary = [[controllerMetadata objectForKey:(NSString*)kCGImagePropertyExifDictionary]mutableCopy];
[[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0]; if (EXIFDictionary) {
} [self.metadata setObject:EXIFDictionary forKey:(NSString*)kCGImagePropertyExifDictionary];
[[self locationManager] startUpdatingLocation];
} }
if (IsAtLeastiOSVersion(@"8.0")) {
[[self locationManager] performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0];
}
[[self locationManager] startUpdatingLocation];
} }
} }
} }