From d3eada4ec2a1b825aaacc1e3ad9fc1cd4da09ee5 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 1 Apr 2019 22:18:18 +0200 Subject: bonne: avoid division by zero Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14010 Credit to OSS Fuzz --- src/projections/bonne.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3