diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-04-25 19:17:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-25 19:17:32 +0200 |
| commit | 04e4f90f0278978c54b753379fca311e41543003 (patch) | |
| tree | 509a7d5bb01663fd500d42147877ddb30fe8e835 | |
| parent | 4c7364ba84b97fc87270386906af66522feea94f (diff) | |
| parent | 9215789383f4f56a2d989a07bfcbddcaf7ee4736 (diff) | |
| download | PROJ-04e4f90f0278978c54b753379fca311e41543003.tar.gz PROJ-04e4f90f0278978c54b753379fca311e41543003.zip | |
Merge pull request #1443 from rouault/ossfuzz_14421
gs50 and other mod_ster projections: avoid divison by zero
| -rw-r--r-- | src/projections/mod_ster.cpp | 7 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/projections/mod_ster.cpp b/src/projections/mod_ster.cpp index b26ea289..50f66839 100644 --- a/src/projections/mod_ster.cpp +++ b/src/projections/mod_ster.cpp @@ -35,7 +35,12 @@ static PJ_XY e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */ pow((1. - esphi) / (1. + esphi), P->e * .5)) - M_HALFPI; schi = sin(chi); cchi = cos(chi); - s = 2. / (1. + Q->schio * schi + Q->cchio * cchi * coslon); + const double denom = 1. + Q->schio * schi + Q->cchio * cchi * coslon; + if( denom == 0 ) { + proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); + return xy; + } + s = 2. / denom; p.r = s * cchi * sinlon; p.i = s * (Q->cchio * schi - Q->schio * cchi * coslon); p = pj_zpoly1(p, Q->zcoeff, Q->n); diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index 3953a1b6..08b8c9b2 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -1853,6 +1853,10 @@ expect 4030931.833981509 1323687.864777399 accept -80.000000000 36.000000000 expect 3450764.261536101 -175619.041820732 +# For some reason, does not fail on MacOSX +#accept 60 -45 +#expect failure errno tolerance_condition + direction inverse accept -1800000.000000000 2600000.000000000 expect -157.989285000 64.851559610 |
