diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-09-17 19:01:04 +0000 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-09-17 19:01:04 +0000 |
| commit | bf53610d87d2b2bcd9afde73915fb2f548f9dd4b (patch) | |
| tree | 4b3894dc9af809e507815a7c2f35dbbdfb8b9adf /src/geocent.cpp | |
| parent | 374f934014d18356f02edd87f1681859afa5a218 (diff) | |
| download | PROJ-bf53610d87d2b2bcd9afde73915fb2f548f9dd4b.tar.gz PROJ-bf53610d87d2b2bcd9afde73915fb2f548f9dd4b.zip | |
pj_Convert_Geocentric_To_Geodetic(): avoid division by zero on weird input coordinates and ellipsoid values. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14766
Diffstat (limited to 'src/geocent.cpp')
| -rw-r--r-- | src/geocent.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/geocent.cpp b/src/geocent.cpp index c023bdd3..dd14af35 100644 --- a/src/geocent.cpp +++ b/src/geocent.cpp @@ -399,7 +399,15 @@ void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi, */ CT = Z/RR; ST = P/RR; - RX = 1.0/sqrt(1.0-gi->Geocent_e2*(2.0-gi->Geocent_e2)*ST*ST); + const double denominator = 1.0-gi->Geocent_e2*(2.0-gi->Geocent_e2)*ST*ST; + if( denominator == 0 ) + { + *Latitude = HUGE_VAL; + *Longitude = HUGE_VAL; + *Height = HUGE_VAL; + return; + } + RX = 1.0/sqrt(denominator); CPHI0 = ST*(1.0-gi->Geocent_e2)*RX; SPHI0 = CT*RX; iter = 0; |
