diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2021-04-20 23:09:01 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2021-04-20 23:19:25 +0300 |
commit | 6244876488f41c4aec8e55ede37625b5bc649bbd (patch) | |
tree | 413432f7bb8fa76cde7e81019eb41be28b789648 | |
parent | 922e676b43c7b5cb0f20ca67c6d2222e2fc5ec03 (diff) | |
download | mariadb-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.cc | 1 | ||||
-rw-r--r-- | sql/event_data_objects.h | 2 | ||||
-rw-r--r-- | sql/event_queue.cc | 1 |
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; } |