summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorholyfoot@hf-ibm.(none) <>2005-05-06 19:04:58 +0500
committerholyfoot@hf-ibm.(none) <>2005-05-06 19:04:58 +0500
commit5aa0edf34c4bf83eace609e2e60b448fcb9553fe (patch)
tree9567d00a7dd4b1a7be9aa7f2d48b28753a9c1a52 /strings/decimal.c
parent82f4a0b021d68b30112d5f0c33118b6412e62d69 (diff)
downloadmariadb-git-5aa0edf34c4bf83eace609e2e60b448fcb9553fe.tar.gz
Trimmed fix for bug #9546 (Crashing with huge decimals)
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;