diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-11-16 17:58:50 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-11-16 17:58:50 +0000 |
commit | 5ac802a9d07dcbaae34c7a9d4f6a51947d35eff2 (patch) | |
tree | bc33544c1ccffb950dcb95db53d993f7c4931e40 | |
parent | 66bd41bfc05eb69f459a65f21803507585672e25 (diff) | |
download | mpfr-5ac802a9d07dcbaae34c7a9d4f6a51947d35eff2.tar.gz |
Integer overflows checked.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1562 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | add1.c | 2 | ||||
-rw-r--r-- | mpz_set_fr.c | 7 |
2 files changed, 6 insertions, 3 deletions
@@ -210,7 +210,7 @@ mpfr_add1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, /* determine rounding and sticky bits (and possible carry) */ - difw = an - diff_exp / BITS_PER_MP_LIMB; + difw = (mp_exp_t) an - (mp_exp_t) (diff_exp / BITS_PER_MP_LIMB); /* difw is the number of limbs from b (regarded as having an infinite precision) that have already been combined with c; -n if the next n limbs from b won't be combined with c. */ diff --git a/mpz_set_fr.c b/mpz_set_fr.c index 1d0f1429d..b8978d469 100644 --- a/mpz_set_fr.c +++ b/mpz_set_fr.c @@ -30,7 +30,8 @@ MA 02111-1307, USA. */ mp_exp_t mpz_set_fr (mpz_ptr z, mpfr_srcptr f) { - int fn, sh; + mp_size_t fn; + int sh; MPFR_ASSERTN(MPFR_IS_FP(f)); @@ -40,7 +41,7 @@ mpz_set_fr (mpz_ptr z, mpfr_srcptr f) if (ALLOC(z) < fn) MPZ_REALLOC(z, fn); - sh = fn * BITS_PER_MP_LIMB - MPFR_PREC(f); + sh = (mp_prec_t) fn * BITS_PER_MP_LIMB - MPFR_PREC(f); if (sh) mpn_rshift (PTR(z), MPFR_MANT(f), fn, sh); else @@ -48,5 +49,7 @@ mpz_set_fr (mpz_ptr z, mpfr_srcptr f) SIZ(z) = fn; + MPFR_ASSERTN((mp_exp_unsigned_t) MPFR_EXP(f) - MPFR_EMIN_MIN + >= (mp_exp_unsigned_t) MPFR_PREC(f)); return MPFR_EXP(f) - MPFR_PREC(f); } |