Commit 62448764 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

MDEV-24807:A possibility for double free in dtor of Event_queue_element_for_exec in the case of OOM

Eliminate a memory leak when init can fail by forgetting to delete the
Event_queue_element_for_exec object.
parent 922e676b
...@@ -178,6 +178,7 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n) ...@@ -178,6 +178,7 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME)))) if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME))))
{ {
my_free(dbname.str); my_free(dbname.str);
dbname.str= NULL;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
......
...@@ -33,7 +33,7 @@ struct TABLE; ...@@ -33,7 +33,7 @@ struct TABLE;
class Event_queue_element_for_exec class Event_queue_element_for_exec
{ {
public: public:
Event_queue_element_for_exec(){}; Event_queue_element_for_exec() : dbname{NULL, 0}, name{NULL, 0} {};
~Event_queue_element_for_exec(); ~Event_queue_element_for_exec();
bool bool
......
...@@ -635,6 +635,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd, ...@@ -635,6 +635,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
if (!(*event_name= new Event_queue_element_for_exec()) || if (!(*event_name= new Event_queue_element_for_exec()) ||
(*event_name)->init(top->dbname, top->name)) (*event_name)->init(top->dbname, top->name))
{ {
delete *event_name;
ret= TRUE; ret= TRUE;
break; break;
} }
......
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