From a7c43a684ac390636f2859dfe5cf65fb4be8f75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 26 Jan 2016 14:49:25 +0200 Subject: [PATCH] MDEV-9304: MariaDB crash with specific query tmp_join may get its tables freed twice during JOIN cleanup. Set them to NULL when the tmp_join is different than the current join. --- sql/sql_union.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 87d3e86b2c7d5..95ce1c9b9404f 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -887,6 +887,12 @@ bool st_select_lex_unit::cleanup() join->tables_list= 0; join->table_count= 0; join->top_join_tab_count= 0; + if (join->tmp_join && join->tmp_join != join) + { + join->tmp_join->tables_list= 0; + join->tmp_join->table_count= 0; + join->tmp_join->top_join_tab_count= 0; + } } error|= fake_select_lex->cleanup(); /*