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/ldbl-128/s_scalbnl.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/ldbl-128/s_scalbnl.c')
-rw-r--r-- | sysdeps/ieee754/ldbl-128/s_scalbnl.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sysdeps/ieee754/ldbl-128/s_scalbnl.c b/sysdeps/ieee754/ldbl-128/s_scalbnl.c index b9de0f74fc..a928ecccec 100644 --- a/sysdeps/ieee754/ldbl-128/s_scalbnl.c +++ b/sysdeps/ieee754/ldbl-128/s_scalbnl.c @@ -46,10 +46,12 @@ long double __scalbnl (long double x, int n) k = ((hx>>48)&0x7fff) - 114; } if (k==0x7fff) return x+x; /* NaN or Inf */ - k = k+n; - if (n> 50000 || k > 0x7ffe) - return huge*__copysignl(huge,x); /* overflow */ if (n< -50000) return tiny*__copysignl(tiny,x); /*underflow*/ + if (n> 50000 || k+n > 0x7ffe) + return huge*__copysignl(huge,x); /* overflow */ + /* Now k and n are bounded we know that k = k+n does not + overflow. */ + k = k+n; if (k > 0) /* normal result */ {SET_LDOUBLE_MSW64(x,(hx&0x8000ffffffffffffULL)|(k<<48)); return x;} if (k <= -114) |