summaryrefslogtreecommitdiff
path: root/sql/sql_statistics.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2019-08-13 19:29:59 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2019-08-13 20:45:51 +0300
commit588e67956af5c21191189f669f11f083e8ae35f7 (patch)
treebb868d9d7e02fc1b2158fbd013829303476f793f /sql/sql_statistics.cc
parentc738aa240e5bea8292e099affd988a6f95268e12 (diff)
downloadmariadb-git-588e67956af5c21191189f669f11f083e8ae35f7.tar.gz
Make sure histograms do not write uninitialized bytes to record
A histogram size that is odd in size with DOUBLE precision will leave the last byte unwritten. When collecting histograms, this causes the last byte to be uninitialized in the record. memset the buffer to 0 first to make sure this does not happen.
Diffstat (limited to 'sql/sql_statistics.cc')
-rw-r--r--sql/sql_statistics.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 37f73adccb3..52b3811e60d 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2109,7 +2109,12 @@ int alloc_statistics_for_table(THD* thd, TABLE *table)
Histogram_type hist_type= (Histogram_type) (thd->variables.histogram_type);
uchar *histogram= NULL;
if (hist_size > 0)
- histogram= (uchar *) alloc_root(&table->mem_root, hist_size * columns);
+ {
+ if ((histogram= (uchar *) alloc_root(&table->mem_root,
+ hist_size * columns)))
+ bzero(histogram, hist_size * columns);
+
+ }
if (!table_stats || !column_stats || !index_stats || !idx_avg_frequency ||
(hist_size && !histogram))