summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorunknown <holyfoot@hf-ibm.(none)>2005-05-06 19:04:58 +0500
committerunknown <holyfoot@hf-ibm.(none)>2005-05-06 19:04:58 +0500
commitf1def25a89e3dc2ed191335e9d5f7843de245e0a (patch)
tree9567d00a7dd4b1a7be9aa7f2d48b28753a9c1a52 /strings/decimal.c
parent0430cdb7c51155de834f7e1268a862d5dd1a0210 (diff)
downloadmariadb-git-f1def25a89e3dc2ed191335e9d5f7843de245e0a.tar.gz
Trimmed fix for bug #9546 (Crashing with huge decimals)
mysql-test/r/type_newdecimal.result: test result fixed mysql-test/t/type_newdecimal.test: test case added sql/my_decimal.cc: error message fixed strings/decimal.c: do_add function fixed
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 4b7dc8803ee..b06a50fc86b 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1612,13 +1612,19 @@ static int do_add(decimal_t *from1, decimal_t *from2, decimal_t *to)
x=intg1 > intg2 ? from1->buf[0] :
intg2 > intg1 ? from2->buf[0] :
from1->buf[0] + from2->buf[0] ;
- if (unlikely(x > DIG_MASK*9)) /* yes, there is */
+ if (unlikely(x > DIG_MAX-1)) /* yes, there is */
{
intg0++;
to->buf[0]=0; /* safety */
}
FIX_INTG_FRAC_ERROR(to->len, intg0, frac0, error);
+ if (unlikely(error == E_DEC_OVERFLOW))
+ {
+ max_decimal(to->len * DIG_PER_DEC1, 0, to);
+ return error;
+ }
+
buf0=to->buf+intg0+frac0;
to->sign=from1->sign;