diff options
author | Praveenkumar Hulakund <praveenkumar.hulakund@oracle.com> | 2013-08-21 10:44:22 +0530 |
---|---|---|
committer | Praveenkumar Hulakund <praveenkumar.hulakund@oracle.com> | 2013-08-21 10:44:22 +0530 |
commit | 39932dcffa9f77f3019673006f54b55dc3f50ef2 (patch) | |
tree | 5c64842b7b3ffcc46f6bbc2bd7bfa57e93d207b2 /sql/sql_class.h | |
parent | 198f3b466cee289a844cffc453da1d3fb7d7c31a (diff) | |
parent | 10a6aa256e965874b3a307f7d81393078a991544 (diff) | |
download | mariadb-git-39932dcffa9f77f3019673006f54b55dc3f50ef2.tar.gz |
Bug#11765252 - READ OF FREED MEMORY WHEN "USE DB" AND
"SHOW PROCESSLIST"
Merging from 5.1 to 5.5
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 64c05fe87c9..2c574e4fa33 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2642,6 +2642,12 @@ public: */ bool set_db(const char *new_db, size_t new_db_len) { + /* + Acquiring mutex LOCK_thd_data as we either free the memory allocated + for the database and reallocating the memory for the new db or memcpy + the new_db to the db. + */ + mysql_mutex_lock(&LOCK_thd_data); /* Do not reallocate memory if current chunk is big enough. */ if (db && new_db && db_length >= new_db_len) memcpy(db, new_db, new_db_len+1); @@ -2654,6 +2660,7 @@ public: db= NULL; } db_length= db ? new_db_len : 0; + mysql_mutex_unlock(&LOCK_thd_data); return new_db && !db; } |