From 55335038504a298a51a0da8cca380cb247695378 Mon Sep 17 00:00:00 2001 From: Thomas Knudsen Date: Wed, 22 Nov 2017 09:39:54 +0100 Subject: Avoid div-by-zero in rf setup --- src/pj_ell_set.c | 4 +++- src/projects.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pj_ell_set.c b/src/pj_ell_set.c index 8ba928b7..18beb875 100644 --- a/src/pj_ell_set.c +++ b/src/pj_ell_set.c @@ -237,6 +237,8 @@ static int pj_shape (PJ *P) { P->rf = pj_atof (pj_param_value (par)); if (HUGE_VAL==P->rf) return proj_errno_set (P, PJD_ERR_INVALID_ARG); + if (0==P->rf) + return proj_errno_set (P, PJD_ERR_REV_FLATTENING_IS_ZERO); P->f = 1 / P->rf; P->es = 2*P->f - P->f*P->f; break; @@ -279,7 +281,7 @@ static int pj_shape (PJ *P) { if (HUGE_VAL==P->b) return proj_errno_set (P, PJD_ERR_INVALID_ARG); if (0==P->b) - return proj_errno_set (P, PJD_ERR_INVALID_ARG); + return proj_errno_set (P, PJD_ERR_ECCENTRICITY_IS_ONE); P->f = (P->a - P->b) / P->a; P->es = 2*P->f - P->f*P->f; break; diff --git a/src/projects.h b/src/projects.h index f8f1fa38..91c0e6a3 100644 --- a/src/projects.h +++ b/src/projects.h @@ -479,14 +479,14 @@ enum deprecated_constants_for_now_dropped_analytical_factors { /* library errors */ #define PJD_ERR_NO_ARGS -1 #define PJD_ERR_NO_OPTION_IN_INIT_FILE -2 -#define PJD_ERR_NO_COLOR_IN_INIT_STRING -3 +#define PJD_ERR_NO_COLON_IN_INIT_STRING -3 #define PJD_ERR_PROJ_NOT_NAMED -4 #define PJD_ERR_UNKNOWN_PROJECTION_ID -5 #define PJD_ERR_ECCENTRICITY_IS_ONE -6 #define PJD_ERR_UNKNOW_UNIT_ID -7 #define PJD_ERR_INVALID_BOOLEAN_PARAM -8 #define PJD_ERR_UNKNOWN_ELLP_PARAM -9 -#define PJD_ERR_REC_FLATTENING_IS_ZERO -10 +#define PJD_ERR_REV_FLATTENING_IS_ZERO -10 #define PJD_ERR_REF_RAD_LARGER_THAN_90 -11 #define PJD_ERR_ES_LESS_THAN_ZERO -12 #define PJD_ERR_MAJOR_AXIS_NOT_GIVEN -13 -- cgit v1.2.3