diff options
author | Gary E. Miller <gem@rellim.com> | 2006-12-28 23:54:43 +0000 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2006-12-28 23:54:43 +0000 |
commit | 4eba5c16e31f3dd44e6aefdd2650052d78923d37 (patch) | |
tree | 1c098b0ba1d36e735c09f4aa63a19528848d00e7 /geoid.c | |
parent | 5fc737b7c4712c08108b2a9c8fb14f9a64834a1b (diff) | |
download | gpsd-4eba5c16e31f3dd44e6aefdd2650052d78923d37.tar.gz |
Add sanity checking to wgs84_separation().
Diffstat (limited to 'geoid.c')
-rw-r--r-- | geoid.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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; |