Commit 4a602046 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-8903: Buildbot valgrind failure: Invalid read of size 1 in sql_memdup...

When we calculate max_key_len for RANGE_OPT_PARAM::min_key/max_key, take
into account that QUICK_RANGE::QUICK_RANGE for some reason assumes
that there is one more byte there:

      max_key((uchar*) sql_memdup(max_key_arg,max_length_arg+1)),
parent 12897947
......@@ -3108,6 +3108,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
param.key_parts_end=key_parts;
param.alloced_sel_args= 0;
max_key_len++; /* Take into account the "+1" in QUICK_RANGE::QUICK_RANGE */
if (!(param.min_key= (uchar*)alloc_root(&alloc,max_key_len)) ||
!(param.max_key= (uchar*)alloc_root(&alloc,max_key_len)))
{
......@@ -3367,6 +3368,7 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
}
}
max_key_len++; /* Take into account the "+1" in QUICK_RANGE::QUICK_RANGE */
if (!(param->min_key= (uchar*)alloc_root(param->mem_root, max_key_len)) ||
!(param->max_key= (uchar*)alloc_root(param->mem_root, max_key_len)))
{
......@@ -4963,6 +4965,7 @@ static bool create_partition_index_description(PART_PRUNE_PARAM *ppar)
if (cur_key_len > max_key_len)
max_key_len= cur_key_len;
max_key_len++; /* Take into account the "+1" in QUICK_RANGE::QUICK_RANGE */
if (!(range_par->min_key= (uchar*)alloc_root(alloc,max_key_len)) ||
!(range_par->max_key= (uchar*)alloc_root(alloc,max_key_len)))
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment