diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-08-23 18:11:43 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-08-23 18:11:43 +0200 |
| commit | 683d3097ff2cabd573a82757e8bef6d8f0447d37 (patch) | |
| tree | 3f61670706b041f7f0d5017b2e4bb1621fbcf484 /src | |
| parent | 403bd8b2674873955eedab1d578586ec2cebdc25 (diff) | |
| download | PROJ-683d3097ff2cabd573a82757e8bef6d8f0447d37.tar.gz PROJ-683d3097ff2cabd573a82757e8bef6d8f0447d37.zip | |
lcc: avoid harmless division by zero in untypical case. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24442
Diffstat (limited to 'src')
| -rw-r--r-- | src/projections/lcc.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/projections/lcc.cpp b/src/projections/lcc.cpp index b78b439c..91ffc511 100644 --- a/src/projections/lcc.cpp +++ b/src/projections/lcc.cpp @@ -140,6 +140,11 @@ PJ *PROJECTION(lcc) { Q->n = log(cosphi / cos(Q->phi2)) / log(tan(M_FORTPI + .5 * Q->phi2) / tan(M_FORTPI + .5 * Q->phi1)); + if( Q->n == 0 ) { + // Likely reason is that phi1 / phi2 are too close to zero. + // Can be reproduced with +proj=lcc +a=1 +lat_2=.0000001 + return pj_default_destructor(P, PJD_ERR_CONIC_LAT_EQUAL); + } Q->c = cosphi * pow(tan(M_FORTPI + .5 * Q->phi1), Q->n) / Q->n; Q->rho0 = (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. : Q->c * pow(tan(M_FORTPI + .5 * P->phi0), -Q->n); |
