Skip to content

Commit f208f6f

Browse files
committed
Safety fix
Ensure that all memory allocated by TABLE_LIST::change_refs_to_fields() is in the same memory root!
1 parent f9c418c commit f208f6f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sql/table.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8822,15 +8822,16 @@ bool TABLE_LIST::change_refs_to_fields()
88228822
List_iterator<Item> li(used_items);
88238823
Item_direct_ref *ref;
88248824
Field_iterator_view field_it;
8825+
Name_resolution_context *ctx;
88258826
THD *thd= table->in_use;
8827+
Item **materialized_items;
88268828
DBUG_ASSERT(is_merged_derived());
88278829

88288830
if (!used_items.elements)
88298831
return FALSE;
88308832

8831-
Item **materialized_items=
8832-
(Item **)thd->calloc(sizeof(void *) * table->s->fields);
8833-
Name_resolution_context *ctx= new Name_resolution_context(this);
8833+
materialized_items= (Item **)thd->calloc(sizeof(void *) * table->s->fields);
8834+
ctx= new (thd->mem_root) Name_resolution_context(this);
88348835
if (!materialized_items || !ctx)
88358836
return TRUE;
88368837

0 commit comments

Comments
 (0)