diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-09-18 16:57:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-18 16:57:19 +0200 |
| commit | 72203ca68e123a237c8c748d39131b702ea4b646 (patch) | |
| tree | 38d1214e399eaaf4e173ad5d13a3820364065c1d /src/geocent.cpp | |
| parent | d2f661fc99615a33d72bb0120a14bca2aaced221 (diff) | |
| parent | bc53524cfbde95ecf6bb134984e68eb715d11c2b (diff) | |
| download | PROJ-72203ca68e123a237c8c748d39131b702ea4b646.tar.gz PROJ-72203ca68e123a237c8c748d39131b702ea4b646.zip | |
Merge pull request #1620 from rouault/ossfuzz_17190_and_others
Assorted set of fixes for boring oss-fuzz related errors (mostly divisions by zero in odd situations)
Diffstat (limited to 'src/geocent.cpp')
| -rw-r--r-- | src/geocent.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/geocent.cpp b/src/geocent.cpp index c023bdd3..cbcc1df5 100644 --- a/src/geocent.cpp +++ b/src/geocent.cpp @@ -399,7 +399,17 @@ 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; @@ -420,7 +430,17 @@ void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi, return; } RK = gi->Geocent_e2*RN/(RN+*Height); - RX = 1.0/sqrt(1.0-RK*(2.0-RK)*ST*ST); + { + const double denominator = 1.0-RK*(2.0-RK)*ST*ST; + if( denominator == 0 ) + { + *Latitude = HUGE_VAL; + *Longitude = HUGE_VAL; + *Height = HUGE_VAL; + return; + } + RX = 1.0/sqrt(denominator); + } CPHI = ST*(1.0-RK)*RX; SPHI = CT*RX; SDPHI = SPHI*CPHI0-CPHI*SPHI0; |
