diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-04-11 00:21:24 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-04-11 00:21:24 +0200 |
| commit | c1e730312965831e6b9c2093677a67716c198622 (patch) | |
| tree | b90bd6f8e54a2f983d1937622de467c80ed49357 /src/projections/omerc.cpp | |
| parent | 00dffd7ace356d7cb39e2c515237d4351f5b5666 (diff) | |
| download | PROJ-c1e730312965831e6b9c2093677a67716c198622.tar.gz PROJ-c1e730312965831e6b9c2093677a67716c198622.zip | |
omerc: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14138
Credit to OSS Fuzz
Diffstat (limited to 'src/projections/omerc.cpp')
| -rw-r--r-- | src/projections/omerc.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/projections/omerc.cpp b/src/projections/omerc.cpp index 4d78fbef..c0278043 100644 --- a/src/projections/omerc.cpp +++ b/src/projections/omerc.cpp @@ -209,8 +209,11 @@ PJ *PROJECTION(omerc) { lam2 += M_TWOPI; P->lam0 = adjlon(.5 * (lam1 + lam2) - atan( J * tan(.5 * Q->B * (lam1 - lam2)) / p) / Q->B); - gamma0 = atan(2. * sin(Q->B * adjlon(lam1 - P->lam0)) / - (F - 1. / F)); + const double denom = F - 1. / F; + if( denom == 0 ) { + return pj_default_destructor(P, PJD_ERR_INVALID_ECCENTRICITY); + } + gamma0 = atan(2. * sin(Q->B * adjlon(lam1 - P->lam0)) / denom); gamma = alpha_c = aasin(P->ctx, D * sin(gamma0)); } Q->singam = sin(gamma0); |
