diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-04-05 14:17:58 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-04-05 14:17:58 +0200 |
| commit | f6ba932a8f1d7f0775d4ebe367b2d5faef57461a (patch) | |
| tree | a602774d5e52071f006b37d59147708a4b57739e /src/projections/imw_p.cpp | |
| parent | a90a5c0b9ac58c322daa8f339719b2c0e09d3d45 (diff) | |
| download | PROJ-f6ba932a8f1d7f0775d4ebe367b2d5faef57461a.tar.gz PROJ-f6ba932a8f1d7f0775d4ebe367b2d5faef57461a.zip | |
imw_p: avoid division by zero in inverse
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14062
Credit to OSS Fuzz
Diffstat (limited to 'src/projections/imw_p.cpp')
| -rw-r--r-- | src/projections/imw_p.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/projections/imw_p.cpp b/src/projections/imw_p.cpp index 41882df2..8d675318 100644 --- a/src/projections/imw_p.cpp +++ b/src/projections/imw_p.cpp @@ -117,12 +117,16 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */ do { t = loc_for(lp, P, &yc); const double denom = t.y - yc; - if( denom == 0 ) { - proj_errno_set(P, PJD_ERR_NON_CONVERGENT); - return proj_coord_error().lp; + if( denom != 0 || fabs(t.y - xy.y) > TOL ) + { + if( denom == 0 ) { + proj_errno_set(P, PJD_ERR_NON_CONVERGENT); + return proj_coord_error().lp; + } + lp.phi = ((lp.phi - Q->phi_1) * (xy.y - yc) / denom) + Q->phi_1; } - lp.phi = ((lp.phi - Q->phi_1) * (xy.y - yc) / denom) + Q->phi_1; - lp.lam = lp.lam * xy.x / t.x; + if( t.x != 0 || fabs(t.x - xy.x) > TOL ) + lp.lam = lp.lam * xy.x / t.x; i ++; } while (i < N_MAX_ITER && (fabs(t.x - xy.x) > TOL || fabs(t.y - xy.y) > TOL)); |
