diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-03 11:51:40 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-06 09:22:51 -0700 |
commit | e6122d9bf0d4b38059ee125fcfcfe7b369907a40 (patch) | |
tree | 528d44f7e296ef2d8fabf34e73919d176d1286c1 /platform/darwin | |
parent | 391a10db0e599f970c989b2db5c6b2dc04597206 (diff) | |
download | qtlocation-mapboxgl-e6122d9bf0d4b38059ee125fcfcfe7b369907a40.tar.gz |
[darwin] Preflight argument validity before constructing mbgl::LatLng
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLGeometry_Private.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index e6b37b3530..ac0ff485aa 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -13,6 +13,18 @@ CGRect MGLExtendRect(CGRect rect, CGPoint point); NS_INLINE mbgl::LatLng MGLLatLngFromLocationCoordinate2D(CLLocationCoordinate2D coordinate) { + if (std::isnan(coordinate.latitude)) { + [NSException raise:NSInvalidArgumentException format:@"latitude must not be NaN"]; + } + if (std::isnan(coordinate.longitude)) { + [NSException raise:NSInvalidArgumentException format:@"longitude must not be NaN"]; + } + if (std::abs(coordinate.latitude) > 90.0) { + [NSException raise:NSInvalidArgumentException format:@"latitude must be between -90 and 90"]; + } + if (!std::isfinite(coordinate.longitude)) { + [NSException raise:NSInvalidArgumentException format:@"longitude must not be infinite"]; + } return mbgl::LatLng(coordinate.latitude, coordinate.longitude); } |