mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-5816: Stored programs: validation of stored program statements
Fixed memory leakage taken place on execution of the statement SHOW CREATE PACKAGE `pkg_name` The memory leak was caused by implementation of sp_compile() where a memory root for a stored routine was allocated but a pointer to the new memory root wasn't passed to sp_package::create for subsequent forwarding to the constructor of sp_package. Instead, another one memory root was allocated and the pointer to the original memory root was missed.
This commit is contained in:
parent
2086f96c6b
commit
6ac1d882a1
3 changed files with 12 additions and 7 deletions
|
@ -607,14 +607,18 @@ sp_head::sp_head(MEM_ROOT *mem_root_arg, sp_package *parent,
|
|||
|
||||
|
||||
sp_package *sp_package::create(LEX *top_level_lex, const sp_name *name,
|
||||
const Sp_handler *sph)
|
||||
const Sp_handler *sph, MEM_ROOT *sp_mem_root)
|
||||
{
|
||||
MEM_ROOT own_root;
|
||||
init_sql_alloc(key_memory_sp_head_main_root, &own_root, MEM_ROOT_BLOCK_SIZE,
|
||||
MEM_ROOT_PREALLOC, MYF(0));
|
||||
if (!sp_mem_root)
|
||||
{
|
||||
init_sql_alloc(key_memory_sp_head_main_root, &own_root, MEM_ROOT_BLOCK_SIZE,
|
||||
MEM_ROOT_PREALLOC, MYF(0));
|
||||
sp_mem_root= &own_root;
|
||||
}
|
||||
sp_package *sp;
|
||||
if (!(sp= new (&own_root) sp_package(&own_root, top_level_lex, name, sph)))
|
||||
free_root(&own_root, MYF(0));
|
||||
if (!(sp= new (sp_mem_root) sp_package(sp_mem_root, top_level_lex, name, sph)))
|
||||
free_root(sp_mem_root, MYF(0));
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
|
|
@ -1061,7 +1061,7 @@ private:
|
|||
~sp_package();
|
||||
public:
|
||||
static sp_package *create(LEX *top_level_lex, const sp_name *name,
|
||||
const Sp_handler *sph);
|
||||
const Sp_handler *sph, MEM_ROOT *sp_mem_root);
|
||||
|
||||
bool add_routine_declaration(LEX *lex)
|
||||
{
|
||||
|
|
|
@ -9386,7 +9386,8 @@ sp_package *LEX::create_package_start(THD *thd,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
if (unlikely(!(pkg= sp_package::create(this, name_arg, sph))))
|
||||
if (unlikely(!(pkg= sp_package::create(this, name_arg, sph,
|
||||
sp_mem_root_ptr))))
|
||||
return NULL;
|
||||
pkg->reset_thd_mem_root(thd);
|
||||
pkg->init(this);
|
||||
|
|
Loading…
Reference in a new issue