summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-07-13 18:03:43 +0400
committerunknown <evgen@moonbone.local>2006-07-13 18:03:43 +0400
commitf783a15aada23772e9aae11f9732dd6e9ed095de (patch)
tree2cbe71ee93beb0e35e0f82632b5dc5dfd539491d /strings
parent4d71b8f8f91fae06641a4913c3cfba6ba8929f57 (diff)
parentfbd9103b7839854201b86ceff2cd1c2b5cedd623 (diff)
downloadmariadb-git-f783a15aada23772e9aae11f9732dd6e9ed095de.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into moonbone.local:/home/evgen/bk-trees/mysql-5.0-opt sql/item.h: Auto merged sql/item_strfunc.cc: Auto merged
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 8786a513945..5a0bc0968b6 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 */ \
@@ -1998,7 +1999,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;