From 456436816b5655c7360c118ee536332fba22b3e1 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Sat, 17 Mar 2018 09:13:21 -0400 Subject: [PATCH] Guard against casting a double NaN to an int. We don't care what value is returned; however, reportedly, a program can crash in this case, see https://github.com/OSGeo/proj.4/issues/843 At present, the fix is only in place for the C library. Still need to handle other cases of float -> int conversion. (A check already in place in the python library.) --- legacy/C/geodesic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/legacy/C/geodesic.c b/legacy/C/geodesic.c index 23557b5..2ca5c5e 100644 --- a/legacy/C/geodesic.c +++ b/legacy/C/geodesic.c @@ -238,7 +238,7 @@ static void sincosdx(real x, real* sinx, real* cosx) { r = remquo(x, (real)(90), &q); #else r = fmod(x, (real)(360)); - q = (int)(floor(r / 90 + (real)(0.5))); + q = r == r ? (int)(floor(r / 90 + (real)(0.5))) : 0; r -= 90 * q; #endif /* now abs(r) <= 45 */