summaryrefslogtreecommitdiff
path: root/geoid.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2012-05-06 13:15:16 -0700
committerGary E. Miller <gem@rellim.com>2012-05-06 13:15:16 -0700
commit203729b88a7204e7d1e63991c882388ceb625c72 (patch)
tree19e77543d62b3ffe71b5f0929eac87b4d1236cd4 /geoid.c
parentaee04a1b71a48fce168e9efedc51e282ddec0401 (diff)
downloadgpsd-203729b88a7204e7d1e63991c882388ceb625c72.tar.gz
Fix a segfault in geoid computation.
Problem found by: "Bywater, Rick (SA-1)" <rbywater@drs-ts.com> Patch by: Beat Bolli <bbolli@ewanet.ch>
Diffstat (limited to 'geoid.c')
-rw-r--r--geoid.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/geoid.c b/geoid.c
index a0feaf45..f055b373 100644
--- a/geoid.c
+++ b/geoid.c
@@ -72,12 +72,9 @@ double wgs84_separation(double lat, double lon)
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;
- }
+ if ((GEOID_ROW <= ilat) || (0 > ilat) ||
+ (GEOID_COL <= ilon) || (0 > ilon))
+ return 0.0;
ilat1 = ilat;
ilon1 = ilon;