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.
This commit is contained in:
Vicențiu Ciorbaru 2019-08-13 19:29:59 +03:00
parent c738aa240e
commit 588e67956a

View file

@ -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))