summaryrefslogtreecommitdiff
path: root/sql/my_decimal.cc
diff options
context:
space:
mode:
authorTatjana Azundris Nuernberg <tatjana.nuernberg@oracle.com>2011-05-12 04:05:12 +0100
committerTatjana Azundris Nuernberg <tatjana.nuernberg@oracle.com>2011-05-12 04:05:12 +0100
commite0c0bf323bd26c011842c7d97ab7ec5ee4b5d80d (patch)
treec05960ee2cf34663d49c4cbf04a9eb7ee6e3712a /sql/my_decimal.cc
parent99a8398f42270ac106b8b7893b76deb0603d2b70 (diff)
parent9990ab901bbe1a99538d062d7b13c29ad84823a9 (diff)
downloadmariadb-git-e0c0bf323bd26c011842c7d97ab7ec5ee4b5d80d.tar.gz
auto-merge Bug#11762799/Bug#55436
Diffstat (limited to 'sql/my_decimal.cc')
-rw-r--r--sql/my_decimal.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index a5b60739b26..3b5fa81eab9 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -99,10 +99,11 @@ int my_decimal2string(uint mask, const my_decimal *d,
UNSIGNED. Hence the buffer for a ZEROFILLed value is the length
the user requested, plus one for a possible decimal point, plus
one if the user only wanted decimal places, but we force a leading
- zero on them. Because the type is implicitly UNSIGNED, we do not
- need to reserve a character for the sign. For all other cases,
- fixed_prec will be 0, and my_decimal_string_length() will be called
- instead to calculate the required size of the buffer.
+ zero on them, plus one for the '\0' terminator. Because the type
+ is implicitly UNSIGNED, we do not need to reserve a character for
+ the sign. For all other cases, fixed_prec will be 0, and
+ my_decimal_string_length() will be called instead to calculate the
+ required size of the buffer.
*/
int length= (fixed_prec
? (fixed_prec + ((fixed_prec == fixed_dec) ? 1 : 0) + 1)
@@ -332,7 +333,7 @@ print_decimal_buff(const my_decimal *dec, const uchar* ptr, int length)
const char *dbug_decimal_as_string(char *buff, const my_decimal *val)
{
- int length= DECIMAL_MAX_STR_LENGTH;
+ int length= DECIMAL_MAX_STR_LENGTH + 1; /* minimum size for buff */
if (!val)
return "NULL";
(void)decimal2string((decimal_t*) val, buff, &length, 0,0,0);