Commit aebd2397 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-34404 Use safe_str in spider udfs to avoid passing NULL str

parent 8b169949
...@@ -4580,7 +4580,7 @@ class THD: public THD_count, /* this must be first */ ...@@ -4580,7 +4580,7 @@ class THD: public THD_count, /* this must be first */
to->length= db.length; to->length= db.length;
return to->str == NULL; /* True on error */ return to->str == NULL; /* True on error */
} }
/* Get db name or "". Use for printing current db */ /* Get db name or "". */
const char *get_db() const char *get_db()
{ return safe_str(db.str); } { return safe_str(db.str); }
......
...@@ -52,7 +52,7 @@ int spider_udf_set_copy_tables_param_default( ...@@ -52,7 +52,7 @@ int spider_udf_set_copy_tables_param_default(
copy_tables->database_length = SPIDER_THD_db_length(copy_tables->trx->thd); copy_tables->database_length = SPIDER_THD_db_length(copy_tables->trx->thd);
if ( if (
!(copy_tables->database = spider_create_string( !(copy_tables->database = spider_create_string(
SPIDER_THD_db_str(copy_tables->trx->thd), copy_tables->trx->thd->get_db(),
copy_tables->database_length)) copy_tables->database_length))
) { ) {
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
......
...@@ -1109,7 +1109,7 @@ int spider_udf_set_direct_sql_param_default( ...@@ -1109,7 +1109,7 @@ int spider_udf_set_direct_sql_param_default(
direct_sql->tgt_default_db_name_length = SPIDER_THD_db_length(trx->thd); direct_sql->tgt_default_db_name_length = SPIDER_THD_db_length(trx->thd);
if ( if (
!(direct_sql->tgt_default_db_name = spider_create_string( !(direct_sql->tgt_default_db_name = spider_create_string(
SPIDER_THD_db_str(trx->thd), trx->thd->get_db(),
direct_sql->tgt_default_db_name_length)) direct_sql->tgt_default_db_name_length))
) { ) {
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
......
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