summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorPraveenkumar Hulakund <praveenkumar.hulakund@oracle.com>2013-08-21 10:44:22 +0530
committerPraveenkumar Hulakund <praveenkumar.hulakund@oracle.com>2013-08-21 10:44:22 +0530
commit7fffec875ac3be244affff4c86b34bd61af11487 (patch)
tree5c64842b7b3ffcc46f6bbc2bd7bfa57e93d207b2 /sql/sql_class.h
parentfcc0011438caaf94f7716ffe4e99bab2e7d17be1 (diff)
parent3b1e98d21844b0f32f6e5fe9df447046eb471453 (diff)
downloadmariadb-git-7fffec875ac3be244affff4c86b34bd61af11487.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.h9
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;
}