summaryrefslogtreecommitdiff
path: root/src/setmax.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-02-22 03:53:19 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-02-22 03:53:19 +0000
commit89b1f422fad8c50cd46b69748624d312922ef881 (patch)
treedad278625378912197929a89552863c7942f688b /src/setmax.c
parent6e9a7ddd09869245d0f46db6493370e0d9a98e54 (diff)
downloadmpfr-89b1f422fad8c50cd46b69748624d312922ef881.tar.gz
Avoid potential integer overflows and improve consistency. This should
fix bug #13918 "Segfault with precision = MPFR_PREC_MAX on 32-bit". Note: this problem appeared in MPFR 3.0.0 when the precision type (now mpfr_prec_t) was changed to a signed integer. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8025 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/setmax.c')
-rw-r--r--src/setmax.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/setmax.c b/src/setmax.c
index 6c41e0e26..f9a77da8d 100644
--- a/src/setmax.c
+++ b/src/setmax.c
@@ -32,7 +32,7 @@ mpfr_setmax (mpfr_ptr x, mpfr_exp_t e)
mp_limb_t *xp;
MPFR_SET_EXP (x, e);
- xn = 1 + (MPFR_PREC(x) - 1) / GMP_NUMB_BITS;
+ xn = MPFR_LIMB_SIZE (x);
sh = (mpfr_prec_t) xn * GMP_NUMB_BITS - MPFR_PREC(x);
xp = MPFR_MANT(x);
xp[0] = MP_LIMB_T_MAX << sh;