From 588e67956af5c21191189f669f11f083e8ae35f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 13 Aug 2019 19:29:59 +0300 Subject: 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. --- sql/sql_statistics.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sql/sql_statistics.cc') 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)) -- cgit v1.2.1