aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-03-26 21:55:56 +0000
committerEven Rouault <even.rouault@spatialys.com>2019-03-26 21:55:56 +0000
commit3e85ebc697ccfc439a2b80488a5056e576c1acea (patch)
tree8b031345b9c28c5568778c75bc26378a31aa5454
parentfb95a6ff7b7a888f8818e9fb65aaa26292813eda (diff)
downloadPROJ-3e85ebc697ccfc439a2b80488a5056e576c1acea.tar.gz
PROJ-3e85ebc697ccfc439a2b80488a5056e576c1acea.zip
misrsom inverse: avoid division by zero
Fixes testcase https://oss-fuzz.com/testcase-detail/5768588923764736 of https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13894
-rw-r--r--src/projections/misrsom.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/projections/misrsom.cpp b/src/projections/misrsom.cpp
index c53f22a1..d16dd62d 100644
--- a/src/projections/misrsom.cpp
+++ b/src/projections/misrsom.cpp
@@ -151,10 +151,14 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */
lamdp -= TOL;
spp = sin(phidp);
sppsq = spp * spp;
+ const double denom = 1. - sppsq * (1. + Q->u);
+ if( denom == 0.0 ) {
+ proj_errno_set(P, PJD_ERR_NON_CONVERGENT);
+ return proj_coord_error().lp;
+ }
lamt = atan(((1. - sppsq * P->rone_es) * tan(lamdp) *
Q->ca - spp * Q->sa * sqrt((1. + Q->q * dd) * (
- 1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / (1. - sppsq
- * (1. + Q->u)));
+ 1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / denom);
sl = lamt >= 0. ? 1. : -1.;
scl = cos(lamdp) >= 0. ? 1. : -1;
lamt -= M_HALFPI * (1. - scl) * sl;