diff options
author | evgen@sunlight.local <> | 2006-07-30 00:33:24 +0400 |
---|---|---|
committer | evgen@sunlight.local <> | 2006-07-30 00:33:24 +0400 |
commit | ef4f14953640962c405e7df7fdb803daaa878128 (patch) | |
tree | 7459ead6708231c323be75b3f99c455341370348 /strings/decimal.c | |
parent | 8cd88a91794e37ec05509ef5ea121bcb69eef0c9 (diff) | |
parent | 3ca575dc896753f9dd52f45eaf983219d5cbd899 (diff) | |
download | mariadb-git-ef4f14953640962c405e7df7fdb803daaa878128.tar.gz |
Merge sunlight.local:/local_work/tmp_merge-5.0-opt-mysql
into sunlight.local:/local_work/tmp_merge-5.1-opt-mysql
Diffstat (limited to 'strings/decimal.c')
-rw-r--r-- | strings/decimal.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/strings/decimal.c b/strings/decimal.c index 7ed2d8f53df..736dc2e57c4 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -171,6 +171,7 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={ do \ { \ dec1 a=(from1)+(from2)+(carry); \ + DBUG_ASSERT((carry) <= 1); \ if (((carry)= a >= DIG_BASE)) /* no division here! */ \ a-=DIG_BASE; \ (to)=a; \ @@ -179,7 +180,7 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={ #define ADD2(to, from1, from2, carry) \ do \ { \ - dec1 a=(from1)+(from2)+(carry); \ + dec2 a=((dec2)(from1))+(from2)+(carry); \ if (((carry)= a >= DIG_BASE)) \ a-=DIG_BASE; \ if (unlikely(a >= DIG_BASE)) \ @@ -187,7 +188,7 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={ a-=DIG_BASE; \ carry++; \ } \ - (to)=a; \ + (to)=(dec1) a; \ } while(0) #define SUB(to, from1, from2, carry) /* to=from1-from2 */ \ @@ -2004,7 +2005,13 @@ int decimal_mul(decimal_t *from1, decimal_t *from2, decimal_t *to) ADD2(*buf0, *buf0, lo, carry); carry+=hi; } - for (; carry; buf0--) + if (carry) + { + if (buf0 < to->buf) + return E_DEC_OVERFLOW; + ADD2(*buf0, *buf0, 0, carry); + } + for (buf0--; carry; buf0--) { if (buf0 < to->buf) return E_DEC_OVERFLOW; |