Skip to content

Commit

Permalink
Merge 7d898d4 into a6bb3c4
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Apr 14, 2019
2 parents a6bb3c4 + 7d898d4 commit e8c5c0a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/projections/imw_p.cpp
Expand Up @@ -125,7 +125,7 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */
}
lp.phi = ((lp.phi - Q->phi_1) * (xy.y - yc) / denom) + Q->phi_1;
}
if( t.x != 0 || fabs(t.x - xy.x) > TOL )
if( t.x != 0 && fabs(t.x - xy.x) > TOL )
lp.lam = lp.lam * xy.x / t.x;
i ++;
} while (i < N_MAX_ITER &&
Expand Down
7 changes: 6 additions & 1 deletion src/projections/lcc.cpp
Expand Up @@ -121,7 +121,12 @@ PJ *PROJECTION(lcc) {
if( ml2 == 0 ) {
return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90);
}
Q->n /= log(ml1 / ml2);
const double denom = log(ml1 / ml2);
if( denom == 0 ) {
// Not quite, but es is very close to 1...
return pj_default_destructor(P, PJD_ERR_INVALID_ECCENTRICITY);
}
Q->n /= denom;
}
Q->c = (Q->rho0 = m1 * pow(ml1, -Q->n) / Q->n);
Q->rho0 *= (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. :
Expand Down
9 changes: 8 additions & 1 deletion test/gie/builtins.gie
Expand Up @@ -2740,7 +2740,14 @@ expect 1 2

-------------------------------------------------------------------------------
operation +proj=lcc +a=9999999 +b=.9 +lat_2=1
-------------------------------------------------------------------------
-------------------------------------------------------------------------------
expect failure errno invalid_eccentricity

-------------------------------------------------------------------------------
# This case is incredible. ossfuzz has found the exact value of lat_1 that
# triggers a division by zero
operation +proj=lcc +lat_1=2D32 +lat_2=0 +a=6378137 +b=0.2
-------------------------------------------------------------------------------
expect failure errno invalid_eccentricity

-------------------------------------------------------------------------------
Expand Down

0 comments on commit e8c5c0a

Please sign in to comment.