Skip to content

Commit

Permalink
Guard against casting a double NaN to an int. We don't care what value
Browse files Browse the repository at this point in the history
is returned; however, reportedly, a program can crash in this case, see

  OSGeo/PROJ#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.)
  • Loading branch information
Charles Karney committed Mar 17, 2018
1 parent d07859b commit 4564368
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion legacy/C/geodesic.c
Expand Up @@ -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 */
Expand Down

0 comments on commit 4564368

Please sign in to comment.