aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-04-01 20:05:22 +0000
committerEven Rouault <even.rouault@spatialys.com>2019-04-01 20:06:03 +0000
commit1e85de97007d9b56a509a4ed866689a3f7c56d77 (patch)
tree10fcd6bb1e857342cfa6ad49370f7dc7e66af2ed /src
parent50d646decf2558de33a83a1b9c1de9f8717988ab (diff)
downloadPROJ-1e85de97007d9b56a509a4ed866689a3f7c56d77.tar.gz
PROJ-1e85de97007d9b56a509a4ed866689a3f7c56d77.zip
pj_gauss_ini(): fix division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14003 Credit to OSS Fuzz
Diffstat (limited to 'src')
-rw-r--r--src/gauss.cpp9
1 files changed, 7 insertions, 2 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);
}