Skip to content

Commit 4a60204

Browse files
committed
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)),
1 parent 1289794 commit 4a60204

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sql/opt_range.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3108,6 +3108,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
31083108
param.key_parts_end=key_parts;
31093109
param.alloced_sel_args= 0;
31103110

3111+
max_key_len++; /* Take into account the "+1" in QUICK_RANGE::QUICK_RANGE */
31113112
if (!(param.min_key= (uchar*)alloc_root(&alloc,max_key_len)) ||
31123113
!(param.max_key= (uchar*)alloc_root(&alloc,max_key_len)))
31133114
{
@@ -3367,6 +3368,7 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param,
33673368
}
33683369
}
33693370

3371+
max_key_len++; /* Take into account the "+1" in QUICK_RANGE::QUICK_RANGE */
33703372
if (!(param->min_key= (uchar*)alloc_root(param->mem_root, max_key_len)) ||
33713373
!(param->max_key= (uchar*)alloc_root(param->mem_root, max_key_len)))
33723374
{
@@ -4963,6 +4965,7 @@ static bool create_partition_index_description(PART_PRUNE_PARAM *ppar)
49634965
if (cur_key_len > max_key_len)
49644966
max_key_len= cur_key_len;
49654967

4968+
max_key_len++; /* Take into account the "+1" in QUICK_RANGE::QUICK_RANGE */
49664969
if (!(range_par->min_key= (uchar*)alloc_root(alloc,max_key_len)) ||
49674970
!(range_par->max_key= (uchar*)alloc_root(alloc,max_key_len)))
49684971
{

0 commit comments

Comments
 (0)