aboutsummaryrefslogtreecommitdiff
path: root/src/projections/stere.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-03-24 17:20:51 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-03-24 17:20:51 +0100
commit2e60df106deba4455089143e5ae0a4ea1858a3e1 (patch)
tree9ced8bfcf923dcddb925a3d50eea604a03cf1ead /src/projections/stere.cpp
parentf41da8f8e0f6f41ca522279274da1f2441828eda (diff)
downloadPROJ-2e60df106deba4455089143e5ae0a4ea1858a3e1.tar.gz
PROJ-2e60df106deba4455089143e5ae0a4ea1858a3e1.zip
stere: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13895 Credit to OSS Fuzz
Diffstat (limited to 'src/projections/stere.cpp')
-rw-r--r--src/projections/stere.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/projections/stere.cpp b/src/projections/stere.cpp
index 9836f341..fd9f9827 100644
--- a/src/projections/stere.cpp
+++ b/src/projections/stere.cpp
@@ -55,11 +55,18 @@ static PJ_XY e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */
}
switch (Q->mode) {
- case OBLIQ:
- A = Q->akm1 / (Q->cosX1 * (1. + Q->sinX1 * sinX +
- Q->cosX1 * cosX * coslam));
+ case OBLIQ: {
+ const double denom = Q->cosX1 * (1. + Q->sinX1 * sinX +
+ Q->cosX1 * cosX * coslam);
+ if( denom == 0 ) {
+ proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
+ return proj_coord_error().xy;
+ }
+ A = Q->akm1 / denom;
xy.y = A * (Q->cosX1 * sinX - Q->sinX1 * cosX * coslam);
- goto xmul; /* but why not just xy.x = A * cosX; break; ? */
+ xy.x = A * cosX;
+ break;
+ }
case EQUIT:
/* avoid zero division */
@@ -69,7 +76,6 @@ static PJ_XY e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */
A = Q->akm1 / (1. + cosX * coslam);
xy.y = A * sinX;
}
-xmul:
xy.x = A * cosX;
break;