summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-06-13 11:56:56 +0400
committerAlexander Barkov <bar@mariadb.com>2018-06-13 11:56:56 +0400
commit2412c151916dc65660644a0cd2fe5f34816ea901 (patch)
tree887acf8786b498c06922e52c1a06a16ed7126135 /sql/item_sum.cc
parentae0aefb1c522455b785c2e43636c482cd161e3de (diff)
downloadmariadb-git-2412c151916dc65660644a0cd2fe5f34816ea901.tar.gz
MDEV-15870 Using aggregate and window function in unexpected places can crash the server
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 4cf11e81d3d..cb150db3031 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -68,14 +68,14 @@ size_t Item_sum::ram_limitation(THD *thd)
bool Item_sum::init_sum_func_check(THD *thd)
{
SELECT_LEX *curr_sel= thd->lex->current_select;
- if (!curr_sel->name_visibility_map)
+ if (curr_sel && !curr_sel->name_visibility_map)
{
for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select())
{
curr_sel->name_visibility_map|= (1 << sl-> nest_level);
}
}
- if (!(thd->lex->allow_sum_func & curr_sel->name_visibility_map))
+ if (!curr_sel || !(thd->lex->allow_sum_func & curr_sel->name_visibility_map))
{
my_message(ER_INVALID_GROUP_FUNC_USE, ER_THD(thd, ER_INVALID_GROUP_FUNC_USE),
MYF(0));