aboutsummaryrefslogtreecommitdiff
path: root/src/projections/misrsom.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-03-26 22:55:56 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-03-26 22:55:56 +0100
commitd0ffa6c9702228aa55c7d2f1c887bf547c46b283 (patch)
treefc285fbf1dbceb57ed72fdf684ef9fde76a13d70 /src/projections/misrsom.cpp
parente08b7bddd25349a24a294616e4d9c984c138e531 (diff)
downloadPROJ-d0ffa6c9702228aa55c7d2f1c887bf547c46b283.tar.gz
PROJ-d0ffa6c9702228aa55c7d2f1c887bf547c46b283.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
Diffstat (limited to 'src/projections/misrsom.cpp')
-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;