diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-03-02 15:32:56 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2012-03-02 15:32:56 +0000 |
commit | a6d06d7b86f724046b462115556d0df682f9f703 (patch) | |
tree | 640870a7d978c8a224fe317e862b65fddba6f40e /sysdeps/ieee754/flt-32/s_scalblnf.c | |
parent | 07e12bb391ae84eb74817d42feda42cff7f687e5 (diff) | |
download | glibc-a6d06d7b86f724046b462115556d0df682f9f703.tar.gz glibc-a6d06d7b86f724046b462115556d0df682f9f703.tar.xz glibc-a6d06d7b86f724046b462115556d0df682f9f703.zip |
Fix scalbn, scalbln integer overflow.
Diffstat (limited to 'sysdeps/ieee754/flt-32/s_scalblnf.c')
-rw-r--r-- | sysdeps/ieee754/flt-32/s_scalblnf.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sysdeps/ieee754/flt-32/s_scalblnf.c b/sysdeps/ieee754/flt-32/s_scalblnf.c index 5256c32592..2a2d7ab651 100644 --- a/sysdeps/ieee754/flt-32/s_scalblnf.c +++ b/sysdeps/ieee754/flt-32/s_scalblnf.c @@ -35,11 +35,13 @@ __scalblnf (float x, long int n) k = ((ix&0x7f800000)>>23) - 25; } if (__builtin_expect(k==0xff, 0)) return x+x; /* NaN or Inf */ - k = k+n; - if (__builtin_expect(n> 50000 || k > 0xfe, 0)) - return huge*copysignf(huge,x); /* overflow */ if (__builtin_expect(n< -50000, 0)) return tiny*copysignf(tiny,x); /*underflow*/ + if (__builtin_expect(n> 50000 || k+n > 0xfe, 0)) + return huge*copysignf(huge,x); /* overflow */ + /* Now k and n are bounded we know that k = k+n does not + overflow. */ + k = k+n; if (__builtin_expect(k > 0, 1)) /* normal result */ {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;} if (k <= -25) |