diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2017-05-24 15:36:00 +0200 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2017-05-24 15:36:00 +0200 |
| commit | add78833eb84b40ca6b4b1d3985f287310e76c75 (patch) | |
| tree | 952ab80f1a70d7385d634cec45674f6b10775b8a /src/geocent.c | |
| parent | 6dbcf87705568a1756d7e142f0f6aee52301bd51 (diff) | |
| download | PROJ-add78833eb84b40ca6b4b1d3985f287310e76c75.tar.gz PROJ-add78833eb84b40ca6b4b1d3985f287310e76c75.zip | |
Avoid zero div. in pj_Convert_Geocentric_To_Geodetic().
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1800
Credit to OSS-Fuzz.
Diffstat (limited to 'src/geocent.c')
| -rw-r--r-- | src/geocent.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/geocent.c b/src/geocent.c index 66e2c314..e340e73d 100644 --- a/src/geocent.c +++ b/src/geocent.c @@ -414,6 +414,11 @@ void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi, /* ellipsoidal (geodetic) height */ *Height = P*CPHI0+Z*SPHI0-RN*(1.0-gi->Geocent_e2*SPHI0*SPHI0); + /* avoid zero division */ + if (RN+*Height==0.0) { + *Latitude = 0.0; + return; + } RK = gi->Geocent_e2*RN/(RN+*Height); RX = 1.0/sqrt(1.0-RK*(2.0-RK)*ST*ST); CPHI = ST*(1.0-RK)*RX; |
