diff options
| author | Monty <monty@mariadb.org> | 2023-02-26 18:33:10 +0200 |
|---|---|---|
| committer | Monty <monty@mariadb.org> | 2023-02-27 19:25:44 +0200 |
| commit | 57c526ffb852fb027e25fdc77173d45bdc60b8a2 (patch) | |
| tree | 0865d590f2d9432587fac628cb8525da8bc42caf /sql/select_handler.cc | |
| parent | 0de3be8cfdfc26f5c236eaefe12d03c7b4af22c8 (diff) | |
| download | mariadb-git-57c526ffb852fb027e25fdc77173d45bdc60b8a2.tar.gz | |
Added detection of memory overwrite with multi_mallocbb-10.5-monty
This patch also fixes some bugs detected by valgrind after this
patch:
- Not enough copy_func elements was allocated by Create_tmp_table() which
causes an memory overwrite in Create_tmp_table::add_fields()
I added an ASSERT() to be able to detect this also without valgrind.
The bug was that TMP_TABLE_PARAM::copy_fields was not correctly set
when calling create_tmp_table().
- Aria::empty_bits is not allocated if there is no varchar/char/blob
fields in the table. Fixed code to take this into account.
This cannot cause any issues as this is just a memory access
into other Aria memory and the content of the memory would not be used.
- Aria::last_key_buff was not allocated big enough. This may have caused
issues with rtrees and ma_extra(HA_EXTRA_REMEMBER_POS) as they
would use the same memory area.
- Aria and MyISAM didn't take extended key parts into account, which
caused problems when copying rec_per_key from engine to sql level.
- Mark asan builds with 'asan' in version strihng to detect these in
not_valgrind_build.inc.
This is needed to not have main.sp-no-valgrind fail with asan.
Diffstat (limited to 'sql/select_handler.cc')
| -rw-r--r-- | sql/select_handler.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/sql/select_handler.cc b/sql/select_handler.cc index 795ed8eb641..b0b8e58623d 100644 --- a/sql/select_handler.cc +++ b/sql/select_handler.cc @@ -51,18 +51,19 @@ select_handler::~select_handler() TABLE *select_handler::create_tmp_table(THD *thd, SELECT_LEX *select) { - DBUG_ENTER("select_handler::create_tmp_table"); List<Item> types; TMP_TABLE_PARAM tmp_table_param; + TABLE *table; + DBUG_ENTER("select_handler::create_tmp_table"); + if (select->master_unit()->join_union_item_types(thd, types, 1)) DBUG_RETURN(NULL); tmp_table_param.init(); - tmp_table_param.field_count= types.elements; - - TABLE *table= ::create_tmp_table(thd, &tmp_table_param, types, - (ORDER *) 0, false, 0, - TMP_TABLE_ALL_COLUMNS, 1, - &empty_clex_str, true, false); + tmp_table_param.field_count= tmp_table_param.func_count= types.elements; + table= ::create_tmp_table(thd, &tmp_table_param, types, + (ORDER *) 0, false, 0, + TMP_TABLE_ALL_COLUMNS, 1, + &empty_clex_str, true, false); DBUG_RETURN(table); } |
