summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorjani@ibmlab.site <>2005-05-10 13:34:17 +0300
committerjani@ibmlab.site <>2005-05-10 13:34:17 +0300
commite7c02801a0ac43bca1ba690bc19256ad46eb51a7 (patch)
tree43acfcb50f7fe9cc4c233842250290f6a34d4c16 /strings
parent0d2cb6c8e44869f82f07373a9983286cf389f5f3 (diff)
parent0b5cedca79b476bc4e9f1c1f80745c2982210932 (diff)
downloadmariadb-git-e7c02801a0ac43bca1ba690bc19256ad46eb51a7.tar.gz
Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.0
into ibmlab.site:/home/my/bk/mysql-5.0
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 3fa06132cf1..1e62333ee66 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1162,6 +1162,8 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac)
isize0=intg0*sizeof(dec1)+dig2bytes[intg0x],
fsize0=frac0*sizeof(dec1)+dig2bytes[frac0x],
fsize1=frac1*sizeof(dec1)+dig2bytes[frac1x];
+ const int orig_isize0= isize0;
+ const int orig_fsize0= fsize0;
char *orig_to= to;
buf1= remove_leading_zeroes(from, &from_intg);
@@ -1252,10 +1254,15 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac)
}
if (fsize0 > fsize1)
{
- while (fsize0-- > fsize1)
+ char *to_end= orig_to + orig_fsize0 + orig_isize0;
+
+ while (fsize0-- > fsize1 && to < to_end)
*to++=(uchar)mask;
}
orig_to[0]^= 0x80;
+
+ /* Check that we have written the whole decimal and nothing more */
+ DBUG_ASSERT(to == orig_to + orig_fsize0 + orig_isize0);
return error;
}