summaryrefslogtreecommitdiff
path: root/sub.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2000-11-29 16:29:28 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2000-11-29 16:29:28 +0000
commit260191013f43cc00cf83e1e3e17061bfa6986094 (patch)
treeec3af52323403133105f979f8eb4403635cc76b1 /sub.c
parentd34b8d331b608bb33748f5de25fe48ada4ba9055 (diff)
downloadmpfr-260191013f43cc00cf83e1e3e17061bfa6986094.tar.gz
fixed potential problem in mpfr_sub1 (k=0 and kc<0)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@805 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub.c')
-rw-r--r--sub.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sub.c b/sub.c
index becfd59fd..6c57362a7 100644
--- a/sub.c
+++ b/sub.c
@@ -350,7 +350,8 @@ mpfr_sub1(a, b, c, rnd_mode, diff_exp)
cc -= mpn_sub_1(&c2, bp+k, 1, cp[0]<<(BITS_PER_MP_LIMB-dif));
}
else { /* no more limb from b */
- if (cp[kc+1]<<(BITS_PER_MP_LIMB-dif)) cc=-1;
+ /* warning: if k was 0, kc can be negative here */
+ if ((kc+1>=0) && (cp[kc+1]<<(BITS_PER_MP_LIMB-dif))) cc=-1;
else while ((cc==0) && (kc>=0)) {
if (cp[kc]) cc=-1;
kc--;