summaryrefslogtreecommitdiff
path: root/geoid.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2006-12-28 23:54:43 +0000
committerGary E. Miller <gem@rellim.com>2006-12-28 23:54:43 +0000
commit4eba5c16e31f3dd44e6aefdd2650052d78923d37 (patch)
tree1c098b0ba1d36e735c09f4aa63a19528848d00e7 /geoid.c
parent5fc737b7c4712c08108b2a9c8fb14f9a64834a1b (diff)
downloadgpsd-4eba5c16e31f3dd44e6aefdd2650052d78923d37.tar.gz
Add sanity checking to wgs84_separation().
Diffstat (limited to 'geoid.c')
-rw-r--r--geoid.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/geoid.c b/geoid.c
index 6b6ab94b..8105a2bf 100644
--- a/geoid.c
+++ b/geoid.c
@@ -58,6 +58,14 @@ double wgs84_separation(double lat, double lon)
ilat=(int)floor(( 90.+lat)/10);
ilon=(int)floor((180.+lon)/10);
+ /* sanity checks to prevent segfault on bad data */
+ if ( ( ilat > 90 ) || ( ilat < -90 ) ) {
+ return 0.0;
+ }
+ if ( ( ilon > 180 ) || ( ilon < -180 ) ) {
+ return 0.0;
+ }
+
ilat1=ilat;
ilon1=ilon;
ilat2=(ilat < GEOID_ROW-1)? ilat+1:ilat;