aboutsummaryrefslogtreecommitdiff
path: root/src/projections/vandg.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-03-24 17:11:55 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-03-24 17:11:55 +0100
commitf41da8f8e0f6f41ca522279274da1f2441828eda (patch)
tree8d13b1fb5aec779338fc651dcb093e80cd244c16 /src/projections/vandg.cpp
parent0529b07f81d3c027e101c6e1eddb4685e957934d (diff)
downloadPROJ-f41da8f8e0f6f41ca522279274da1f2441828eda.tar.gz
PROJ-f41da8f8e0f6f41ca522279274da1f2441828eda.zip
vandg inverse: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13894 Credit to OSS Fuzz
Diffstat (limited to 'src/projections/vandg.cpp')
-rw-r--r--src/projections/vandg.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/projections/vandg.cpp b/src/projections/vandg.cpp
index 89620356..c669f8fa 100644
--- a/src/projections/vandg.cpp
+++ b/src/projections/vandg.cpp
@@ -80,7 +80,14 @@ static PJ_LP s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
al = c1 / c3 - THIRD * c2 * c2;
m = 2. * sqrt(-THIRD * al);
d = C2_27 * c2 * c2 * c2 + (c0 * c0 - THIRD * c2 * c1) / c3;
- if (((t = fabs(d = 3. * d / (al * m))) - TOL) <= 1.) {
+ const double al_mul_m = al * m;
+ if( al_mul_m == 0 ) {
+ proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
+ return proj_coord_error().lp;
+ }
+ d = 3. * d /al_mul_m;
+ t = fabs(d);
+ if ((t - TOL) <= 1.) {
d = t > 1. ? (d > 0. ? 0. : M_PI) : acos(d);
lp.phi = M_PI * (m * cos(d * THIRD + PI4_3) - THIRD * c2);
if (xy.y < 0.) lp.phi = -lp.phi;