libc: Prevent infinite recursion when modf is called with NaN or Inf argument. (apply richard millers / modf-nan patch from sources)
This commit is contained in:
parent
508b53a29a
commit
c23a2f6a79
1 changed files with 11 additions and 2 deletions
|
@ -89,6 +89,16 @@ modf(double d, double *ip)
|
|||
FPdbleword x;
|
||||
int e;
|
||||
|
||||
x.x = d;
|
||||
e = (x.hi >> SHIFT) & MASK;
|
||||
if(e == MASK){
|
||||
*ip = d;
|
||||
if(x.lo != 0 || (x.hi & 0xfffffL != 0)) /* NaN */
|
||||
return d;
|
||||
/* ±Inf */
|
||||
x.hi &= 0x80000000L;
|
||||
return x.x;
|
||||
}
|
||||
if(d < 1) {
|
||||
if(d < 0) {
|
||||
x.x = modf(-d, ip);
|
||||
|
@ -98,8 +108,7 @@ modf(double d, double *ip)
|
|||
*ip = 0;
|
||||
return d;
|
||||
}
|
||||
x.x = d;
|
||||
e = ((x.hi >> SHIFT) & MASK) - BIAS;
|
||||
e -= BIAS;
|
||||
if(e <= SHIFT+1) {
|
||||
x.hi &= ~(0x1fffffL >> e);
|
||||
x.lo = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue