summaryrefslogtreecommitdiff
path: root/sql/item_create.cc
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2018-08-24 17:00:32 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2018-08-24 17:00:32 +0530
commit2ccae65cff59c0e65402291ca7eb52caa6d152fd (patch)
treee68c04119d145ed7c6fecd01cfc65648d8c75e5d /sql/item_create.cc
parent5abc79dd7ab2fccb4b05ca38a512ec816d2f8e52 (diff)
downloadmariadb-git-2ccae65cff59c0e65402291ca7eb52caa6d152fd.tar.gz
Fixed ASAN failure for the test main.func_miscbb-10.4-16722
Moved the checks for arguments validation of Item_name_const from the constructor to Create_func_name_const::create_2_arg Also reverted the fix bf1c53e9be84437ada32393bb7b4a8ff06dbf369
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r--sql/item_create.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index d9b007d4728..87bf69f3c96 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -6103,7 +6103,26 @@ Create_func_name_const Create_func_name_const::s_singleton;
Item*
Create_func_name_const::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
- return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
+ if (!arg1->basic_const_item())
+ goto err;
+
+ if (arg2->basic_const_item())
+ return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
+
+ if (arg2->type() == Item::FUNC_ITEM)
+ {
+ Item_func *value_func= (Item_func *) arg2;
+ if (value_func->functype() != Item_func::COLLATE_FUNC &&
+ value_func->functype() != Item_func::NEG_FUNC)
+ goto err;
+
+ if (!value_func->key_item()->basic_const_item())
+ goto err;
+ return new (thd->mem_root) Item_name_const(thd, arg1, arg2);
+ }
+err:
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
+ return NULL;
}