From 00dffd7ace356d7cb39e2c515237d4351f5b5666 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 11 Apr 2019 00:14:26 +0200 Subject: omerc: avoid division by zero when |lat_0|=90 Partially revert e3346bb39c860883ed9a8ada0657139118e21ef0 (#195) Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14136 Credit to OSS Fuzz --- src/projections/omerc.cpp | 3 +++ test/gie/builtins.gie | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/projections/omerc.cpp b/src/projections/omerc.cpp index c33f6489..4d78fbef 100644 --- a/src/projections/omerc.cpp +++ b/src/projections/omerc.cpp @@ -191,6 +191,9 @@ PJ *PROJECTION(omerc) { gamma = alpha_c; } else alpha_c = aasin(P->ctx, D*sin(gamma0 = gamma)); + if( fabs(fabs(P->phi0) - M_HALFPI) <= TOL ) { + return pj_default_destructor(P, PJD_ERR_LAT_0_OR_ALPHA_EQ_90); + } P->lam0 = lamc - aasin(P->ctx, .5 * (F - 1. / F) * tan(gamma0)) / Q->B; } else { diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index adaa98d9..bbaca7ba 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -3962,6 +3962,11 @@ tolerance 1 mm accept 2 1 expect -3569.825230822232 -5093592.310871849768 +------------------------------------------------------------------------------- +operation +proj=omerc +R=1 +alpha=0 +lat_0=90 +------------------------------------------------------------------------------- +expect failure errno lat_0_or_alpha_eq_90 + =============================================================================== Ortelius Oval -- cgit v1.2.3