diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-03-15 22:24:31 +0100 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2019-03-17 08:11:20 +0100 |
| commit | ea3f357c83b8430702a05b0a0120cf435835ee5d (patch) | |
| tree | a0443c62c80e1f340f1840ed3adc0ef0a18af6ec /src | |
| parent | b146ce4dba788c6f7480a999f89e46eea4bdfbf4 (diff) | |
| download | PROJ-ea3f357c83b8430702a05b0a0120cf435835ee5d.tar.gz PROJ-ea3f357c83b8430702a05b0a0120cf435835ee5d.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')
| -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; |
