summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2021-04-20 23:09:01 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2021-04-20 23:19:25 +0300
commit6244876488f41c4aec8e55ede37625b5bc649bbd (patch)
tree413432f7bb8fa76cde7e81019eb41be28b789648
parent922e676b43c7b5cb0f20ca67c6d2222e2fc5ec03 (diff)
downloadmariadb-git-6244876488f41c4aec8e55ede37625b5bc649bbd.tar.gz
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.
-rw-r--r--sql/event_data_objects.cc1
-rw-r--r--sql/event_data_objects.h2
-rw-r--r--sql/event_queue.cc1
3 files changed, 3 insertions, 1 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index 4100a031c91..4e5137d3ee1 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -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))))
{
my_free(dbname.str);
+ dbname.str= NULL;
return TRUE;
}
return FALSE;
diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h
index 0acf301ef5a..41626004100 100644
--- a/sql/event_data_objects.h
+++ b/sql/event_data_objects.h
@@ -33,7 +33,7 @@ struct TABLE;
class Event_queue_element_for_exec
{
public:
- Event_queue_element_for_exec(){};
+ Event_queue_element_for_exec() : dbname{NULL, 0}, name{NULL, 0} {};
~Event_queue_element_for_exec();
bool
diff --git a/sql/event_queue.cc b/sql/event_queue.cc
index 904efe26f36..4398b650fd7 100644
--- a/sql/event_queue.cc
+++ b/sql/event_queue.cc
@@ -635,6 +635,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd,
if (!(*event_name= new Event_queue_element_for_exec()) ||
(*event_name)->init(top->dbname, top->name))
{
+ delete *event_name;
ret= TRUE;
break;
}