Merge pull request #231 from dpa99c/master
fix(ios): Prevent infinite value in returned location data causing app crash
diff --git a/src/ios/CDVLocation.m b/src/ios/CDVLocation.m
index d07a8e9..84bdf15 100644
--- a/src/ios/CDVLocation.m
+++ b/src/ios/CDVLocation.m
@@ -299,8 +299,13 @@
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.latitude] forKey:@"latitude"];
[returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.longitude] forKey:@"longitude"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
- [result setKeepCallbackAsBool:keepCallback];
+ if([NSJSONSerialization isValidJSONObject:returnInfo]){
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
+ [result setKeepCallbackAsBool:keepCallback];
+ }else{
+ // return error
+ result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:POSITIONUNAVAILABLE];
+ }
}
if (result) {
[self.commandDelegate sendPluginResult:result callbackId:callbackId];