aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2017-05-23 23:44:40 +0200
committerKristian Evers <kristianevers@gmail.com>2017-05-24 11:20:09 +0200
commita7b684ec7c750943a1f1f2291090c090b44da729 (patch)
tree51d704577936b722425d80ffc51aeb9b6e933c8e
parent13247554c9e245093da63145d28bdc965a1d52c4 (diff)
downloadPROJ-a7b684ec7c750943a1f1f2291090c090b44da729.tar.gz
PROJ-a7b684ec7c750943a1f1f2291090c090b44da729.zip
Avoid division by zero in pj_ell_set().
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1787 Credit to OSS-Fuzz.
-rw-r--r--src/pj_ell_set.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pj_ell_set.c b/src/pj_ell_set.c
index 865726fa..72892ac2 100644
--- a/src/pj_ell_set.c
+++ b/src/pj_ell_set.c
@@ -74,6 +74,10 @@ int pj_ell_set(projCtx ctx, paralist *pl, double *a, double *es) {
*a = sqrt(*a * b);
*es = 0.;
} else if (pj_param(ctx,pl, "bR_h").i) { /* sphere--harmonic mean */
+ if ( (*a + b) == 0.0) {
+ pj_ctx_set_errno(ctx, -20);
+ goto bomb;
+ }
*a = 2. * *a * b / (*a + b);
*es = 0.;
} else if ((i = pj_param(ctx,pl, "tR_lat_a").i) || /* sphere--arith. */