diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-03-15 22:24:31 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-03-16 10:10:02 +0100 |
| commit | ed2b26a09b407f7b580297d8a2cc516f786cbcc6 (patch) | |
| tree | 014721f64614c8420b402035fd62f8d9781d5f28 /src/projections | |
| parent | 44fc7dda9fc411f7c2f052c2271d563bc52f2518 (diff) | |
| download | PROJ-ed2b26a09b407f7b580297d8a2cc516f786cbcc6.tar.gz PROJ-ed2b26a09b407f7b580297d8a2cc516f786cbcc6.zip | |
Hammer: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12799
Credit to OSS Fuzz
Diffstat (limited to 'src/projections')
| -rw-r--r-- | src/projections/hammer.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/projections/hammer.cpp b/src/projections/hammer.cpp index aa7d1ba9..b2e56a2c 100644 --- a/src/projections/hammer.cpp +++ b/src/projections/hammer.cpp @@ -24,7 +24,14 @@ static PJ_XY s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward */ struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); double cosphi, d; - d = sqrt(2./(1. + (cosphi = cos(lp.phi)) * cos(lp.lam *= Q->w))); + cosphi = cos(lp.phi); + lp.lam *= Q->w; + double denom = 1. + cosphi * cos(lp.lam); + if( denom == 0.0 ) { + proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); + return proj_coord_error().xy; + } + d = sqrt(2./denom); xy.x = Q->m * d * cosphi * sin(lp.lam); xy.y = Q->rm * d * sin(lp.phi); return xy; |
