summaryrefslogtreecommitdiff
path: root/sql/sp_rcontext.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-03-23 17:21:10 +0400
committerAlexander Barkov <bar@mariadb.org>2017-04-05 15:03:01 +0400
commit01457ec280d44e853b95f0e88ad19e66a439abf6 (patch)
tree136c14c1c08417c3c7e307e8bb0b961f43c49ad9 /sql/sp_rcontext.cc
parentec19e48021e408edac2e875cfeeef8f496a04d22 (diff)
downloadmariadb-git-01457ec280d44e853b95f0e88ad19e66a439abf6.tar.gz
MDEV-12347 Valgrind reports invalid read errors in Item_field_row::element_index_by_name
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r--sql/sp_rcontext.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index d60d7f5118f..18f603f932d 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -222,11 +222,18 @@ bool sp_rcontext::resolve_table_rowtype_ref(THD *thd,
{
for (Field **src= lex.query_tables->table->field; *src; src++)
{
+ /*
+ Make field names on the THD memory root,
+ as the table will be closed and freed soon,
+ in the end of this method.
+ */
+ LEX_CSTRING tmp= {src[0]->field_name, strlen(src[0]->field_name)};
if ((rc= check_column_grant_for_type_ref(thd, table_list,
- src[0]->field_name,
- strlen(src[0]->field_name))))
+ tmp.str, tmp.length)) ||
+ (rc= !(src[0]->field_name= thd->strmake(tmp.str, tmp.length))))
break;
Spvar_definition *def= new (thd->mem_root) Spvar_definition(thd, *src);
+ src[0]->field_name= tmp.str; // Restore field name, just in case.
def->flags&= (uint) ~NOT_NULL_FLAG;
if ((rc= def->sp_prepare_create_field(thd, thd->mem_root)))
break;