Commit 246c0b3a authored by Alexander Barkov's avatar Alexander Barkov

MDEV-34227 On startup: UBSAN: runtime error: applying non-zero offset in...

MDEV-34227 On startup: UBSAN: runtime error: applying non-zero offset in JOIN::make_aggr_tables_info in sql/sql_select.cc

Avoid undefined behaviour (applying offset to nullptr).
The reported scenario is covered in mysql-test/connect-no-db.test
No new tests needed.
parent 21f56583
......@@ -3325,7 +3325,8 @@ bool JOIN::make_aggr_tables_info()
{
List<Item> *curr_all_fields= &all_fields;
List<Item> *curr_fields_list= &fields_list;
JOIN_TAB *curr_tab= join_tab + const_tables;
// Avoid UB (applying .. offset to nullptr) when join_tab is nullptr
JOIN_TAB *curr_tab= join_tab ? join_tab + const_tables : nullptr;
TABLE *exec_tmp_table= NULL;
bool distinct= false;
bool keep_row_order= false;
......@@ -3883,9 +3884,9 @@ bool JOIN::make_aggr_tables_info()
- duplicate value removal
Both of these operations are done after window function computation step.
*/
curr_tab= join_tab + total_join_tab_cnt();
if (select_lex->window_funcs.elements)
{
curr_tab= join_tab + total_join_tab_cnt();
if (!(curr_tab->window_funcs_step= new Window_funcs_computation))
DBUG_RETURN(true);
if (curr_tab->window_funcs_step->setup(thd, &select_lex->window_funcs,
......
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