aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Schwehr <schwehr@google.com>2018-03-22 09:06:03 -0700
committerKurt Schwehr <schwehr@google.com>2018-03-22 09:06:03 -0700
commitec494f12d10412d389733a196ec58a4d0c4beffa (patch)
tree18c14fc778dc65d0272535a0576ee0cb068a6f36
parent3c59dad1b6502963bfc8ee74700101f631d3e302 (diff)
downloadPROJ-ec494f12d10412d389733a196ec58a4d0c4beffa.tar.gz
PROJ-ec494f12d10412d389733a196ec58a4d0c4beffa.zip
Handle nan float cast overflow in PJ_robin.c and nad_intr.c
Uses the new pj_is_nan to avoid x == x checks. Removes an assignment from an arg list
-rw-r--r--src/PJ_robin.c6
-rw-r--r--src/nad_intr.c9
2 files changed, 11 insertions, 4 deletions
diff --git a/src/PJ_robin.c b/src/PJ_robin.c
index 7514b325..92aebfd3 100644
--- a/src/PJ_robin.c
+++ b/src/PJ_robin.c
@@ -1,4 +1,5 @@
#define PJ_LIB__
+#include "proj_internal.h"
#include "proj.h"
#include "projects.h"
@@ -80,7 +81,8 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
double dphi;
(void) P;
- i = (int)floor((dphi = fabs(lp.phi)) * C1);
+ dphi = fabs(lp.phi);
+ i = pj_is_nan(lp.phi) ? -1 : (int)floor(dphi * C1);
if( i < 0 ){
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return xy;
@@ -115,7 +117,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
}
} else { /* general problem */
/* in Y space, reduce to table interval */
- i = (int)floor(lp.phi * NODES);
+ i = pj_is_nan(lp.phi) ? -1 : (int)floor(lp.phi * NODES);
if( i < 0 || i >= NODES ) {
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return lp;
diff --git a/src/nad_intr.c b/src/nad_intr.c
index b385410f..dc245831 100644
--- a/src/nad_intr.c
+++ b/src/nad_intr.c
@@ -1,6 +1,8 @@
/* Determine nad table correction value */
#define PJ_LIB__
+#include "proj_internal.h"
#include "projects.h"
+
LP
nad_intr(LP t, struct CTABLE *ct) {
LP val, frct;
@@ -10,8 +12,11 @@ nad_intr(LP t, struct CTABLE *ct) {
long index;
int in;
- indx.lam = (int)floor(t.lam /= ct->del.lam);
- indx.phi = (int)floor(t.phi /= ct->del.phi);
+ t.lam /= ct->del.lam;
+ indx.lam = pj_is_nan(t.lam) ? 0 : (int)floor(t.lam);
+ t.phi /= ct->del.phi;
+ indx.phi = pj_is_nan(t.phi) ? 0 : (int)floor(t.phi);
+
frct.lam = t.lam - indx.lam;
frct.phi = t.phi - indx.phi;
val.lam = val.phi = HUGE_VAL;