aboutsummaryrefslogtreecommitdiff
path: root/src/projections/lsat.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@mines-paris.org>2019-04-11 12:45:33 +0200
committerGitHub <noreply@github.com>2019-04-11 12:45:33 +0200
commit2117c151d62cd0267068075b9e7cf7cc0d404a63 (patch)
treeb90bd6f8e54a2f983d1937622de467c80ed49357 /src/projections/lsat.cpp
parentfb125618fd18f112ed6f37662b021d07a602ff90 (diff)
parentc1e730312965831e6b9c2093677a67716c198622 (diff)
downloadPROJ-2117c151d62cd0267068075b9e7cf7cc0d404a63.tar.gz
PROJ-2117c151d62cd0267068075b9e7cf7cc0d404a63.zip
Merge pull request #1422 from rouault/fix_ossfuzz_14135_and_al
Fix ossfuzz 14135, 14136 and 14138
Diffstat (limited to 'src/projections/lsat.cpp')
-rw-r--r--src/projections/lsat.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/projections/lsat.cpp b/src/projections/lsat.cpp
index 5b7520d3..f9eec1b9 100644
--- a/src/projections/lsat.cpp
+++ b/src/projections/lsat.cpp
@@ -112,7 +112,6 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */
struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque);
int nn;
double lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp;
-
lamdp = xy.x / Q->b;
nn = 50;
do {
@@ -135,10 +134,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_INVALID_X_OR_Y);
+ 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;