aboutsummaryrefslogtreecommitdiff
path: root/src/projections/bonne.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-04-01 22:18:18 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-04-01 22:18:18 +0200
commitd3eada4ec2a1b825aaacc1e3ad9fc1cd4da09ee5 (patch)
tree041cc1ef39d55031878adbcdea832d314e424772 /src/projections/bonne.cpp
parent530913a5517fea6d23daecdb6b4d8d62fcb0a9cc (diff)
downloadPROJ-d3eada4ec2a1b825aaacc1e3ad9fc1cd4da09ee5.tar.gz
PROJ-d3eada4ec2a1b825aaacc1e3ad9fc1cd4da09ee5.zip
bonne: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14010 Credit to OSS Fuzz
Diffstat (limited to 'src/projections/bonne.cpp')
-rw-r--r--src/projections/bonne.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/projections/bonne.cpp b/src/projections/bonne.cpp
index 0e9bae79..289eb23d 100644
--- a/src/projections/bonne.cpp
+++ b/src/projections/bonne.cpp
@@ -26,9 +26,14 @@ static PJ_XY e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */
double rh, E, c;
rh = Q->am1 + Q->m1 - pj_mlfn(lp.phi, E = sin(lp.phi), c = cos(lp.phi), Q->en);
- E = c * lp.lam / (rh * sqrt(1. - P->es * E * E));
- xy.x = rh * sin(E);
- xy.y = Q->am1 - rh * cos(E);
+ if (fabs(rh) > EPS10) {
+ E = c * lp.lam / (rh * sqrt(1. - P->es * E * E));
+ xy.x = rh * sin(E);
+ xy.y = Q->am1 - rh * cos(E);
+ } else {
+ xy.x = 0.;
+ xy.y = 0.;
+ }
return xy;
}