diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-03-29 22:09:16 +0000 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-03-29 22:31:57 +0000 |
| commit | 969c654c2db3c169deb3e70e43fbc764f2ffeecb (patch) | |
| tree | 71eb72bb373e4b1a1c59791334411826be90f80e | |
| parent | da1940a6088d6b770939dd0e93a82e5ee1ab2f18 (diff) | |
| download | PROJ-969c654c2db3c169deb3e70e43fbc764f2ffeecb.tar.gz PROJ-969c654c2db3c169deb3e70e43fbc764f2ffeecb.zip | |
tpeqd: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13948
Credit to OSS Fuzz
| -rw-r--r-- | src/projections/tpeqd.cpp | 4 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/projections/tpeqd.cpp b/src/projections/tpeqd.cpp index 20921de4..9904bb8c 100644 --- a/src/projections/tpeqd.cpp +++ b/src/projections/tpeqd.cpp @@ -87,6 +87,10 @@ PJ *PROJECTION(tpeqd) { Q->sc = Q->sp1 * Q->cp2; Q->ccs = Q->cp1 * Q->cp2 * sin(Q->dlam2); Q->z02 = aacos(P->ctx, Q->sp1 * Q->sp2 + Q->cp1 * Q->cp2 * cos (Q->dlam2)); + if( Q->z02 == 0.0 ) { + // Actually happens when both lat_1 = lat_2 and |lat_1| = 90 + return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); + } Q->hz0 = .5 * Q->z02; A12 = atan2(Q->cp2 * sin (Q->dlam2), Q->cp1 * Q->sp2 - Q->sp1 * Q->cp2 * cos (Q->dlam2)); diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index c8eb3a11..2cc44632 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -5243,7 +5243,7 @@ Two Point Equidistant =============================================================================== ------------------------------------------------------------------------------- -operation +proj=tpeqd +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5 +operation +proj=tpeqd +ellps=GRS80 +lat_1=0.5 +lat_2=2 ------------------------------------------------------------------------------- tolerance 0.18 mm accept 2 1 @@ -5266,7 +5266,7 @@ accept -200 -100 expect 0.000898554 1.248203369 ------------------------------------------------------------------------------- -operation +proj=tpeqd +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5 +operation +proj=tpeqd +a=6400000 +lat_1=0.5 +lat_2=2 ------------------------------------------------------------------------------- tolerance 0.1 mm accept 2 1 @@ -5288,6 +5288,10 @@ expect -0.000895485 1.248209507 accept -200 -100 expect 0.000895485 1.248209507 +------------------------------------------------------------------------------- +operation +proj=tpeqd +a=6400000 +lat_1=90 +lat_2=90 +lon_1=0 +lon_2=1 +------------------------------------------------------------------------------- +expect failure =============================================================================== Tilted perspective |
