aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@mines-paris.org>2019-04-02 13:10:49 +0200
committerGitHub <noreply@github.com>2019-04-02 13:10:49 +0200
commite87b3744350baca2b7fe35070e621a6b45bcbf67 (patch)
tree187c73875abfe12b31b89162f7493ea6e8ff794f /src
parent5d81543d820c3369d4435a314d17cb28a83eb7a3 (diff)
parent6f24ff64af08478868f31288ff1036fe7864faa1 (diff)
downloadPROJ-e87b3744350baca2b7fe35070e621a6b45bcbf67.tar.gz
PROJ-e87b3744350baca2b7fe35070e621a6b45bcbf67.zip
Merge pull request #1404 from OSGeo/backport-1401-to-6.0
[Backport 6.0] Ossfuzz 14003 14010
Diffstat (limited to 'src')
-rw-r--r--src/gauss.cpp9
-rw-r--r--src/projections/bonne.cpp11
2 files changed, 15 insertions, 5 deletions
diff --git a/src/gauss.cpp b/src/gauss.cpp
index 49ccfa1c..a34a8f5b 100644
--- a/src/gauss.cpp
+++ b/src/gauss.cpp
@@ -65,13 +65,18 @@ void *pj_gauss_ini(double e, double phi0, double *chi, double *rc) {
}
*chi = asin(sphi / en->C);
en->ratexp = 0.5 * en->C * e;
+ double srat_val = srat(en->e * sphi, en->ratexp);
+ if (srat_val == 0.0) {
+ free(en);
+ return nullptr;
+ }
if( .5 * phi0 + M_FORTPI < 1e-10 ) {
- en->K = 1.0 / srat(en->e * sphi, en->ratexp);
+ en->K = 1.0 / srat_val;
}
else {
en->K = tan(.5 * *chi + M_FORTPI) / (
pow(tan(.5 * phi0 + M_FORTPI), en->C) *
- srat(en->e * sphi, en->ratexp) );
+ srat_val );
}
return ((void *)en);
}
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;
}