From c6a7e8676289bb90e698f433c2e17f73bbbecee6 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Mon, 29 Jun 2015 20:44:45 +0200 Subject: [PATCH] Lock database before setting character set SQL_SetCharset wasn't thread safe and could race with other threaded queries causing a crash. --- extensions/mysql/mysql/MyDatabase.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/mysql/mysql/MyDatabase.cpp b/extensions/mysql/mysql/MyDatabase.cpp index 84f34537..e5cddf65 100644 --- a/extensions/mysql/mysql/MyDatabase.cpp +++ b/extensions/mysql/mysql/MyDatabase.cpp @@ -297,5 +297,9 @@ IDBDriver *MyDatabase::GetDriver() bool MyDatabase::SetCharacterSet(const char *characterset) { - return mysql_set_character_set(m_mysql, characterset) == 0 ? true : false; + bool res; + LockForFullAtomicOperation(); + res = mysql_set_character_set(m_mysql, characterset) == 0 ? true : false; + UnlockFromFullAtomicOperation(); + return res; }