summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2011-08-29 11:24:36 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2011-08-29 11:24:36 +0200
commitf610c5658748ae97a5e2c1e1afbd229f2121a082 (patch)
treecfdb33c49ffc624e6202046c039fea6682c55126 /strings/decimal.c
parent5618a7d69df06ee7ad3b41a269cba8b57f99a8c5 (diff)
downloadmariadb-git-f610c5658748ae97a5e2c1e1afbd229f2121a082.tar.gz
BUG#12911710 - VALGRIND FAILURE IN ROW-DEBUG:PERFSCHEMA.SOCKET_SUMMARY_BY_INSTANCE_FUNC
Converting the number zero to binary and back yielded the number zero, but with no digits, i.e. zero precision. This made the multiply algorithm go haywire in various ways. include/decimal.h: Document struct st_decimal_t mysql-test/r/type_newdecimal.result: New test case (valgrind warnings) mysql-test/t/type_newdecimal.test: New test case (valgrind warnings) sql/my_decimal.h: Remove the HAVE_purify enabled/disabled code. strings/decimal.c: Make a proper zero, with non-zero precision.
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 43957c7dc19..6c89657004c 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1423,11 +1423,18 @@ int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale)
buf++;
}
my_afree(d_copy);
+
+ /*
+ No digits? We have read the number zero, of unspecified precision.
+ Make it a proper zero, with non-zero precision.
+ */
+ if (to->intg == 0 && to->frac == 0)
+ decimal_make_zero(to);
return error;
err:
my_afree(d_copy);
- decimal_make_zero(((decimal_t*) to));
+ decimal_make_zero(to);
return(E_DEC_BAD_NUM);
}