summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-05-11 11:36:29 +0100
committerSadie Powell <sadie@witchery.services>2024-05-11 11:36:29 +0100
commitafe87bf69354c87506fa7544e4d0945046a5b303 (patch)
treef64eb19cca328cdad0fbed8a559ad88032130462 /modules
parent0c5bf51378bca2c671722940bea188c783c2897b (diff)
Ensure we are connected to MySQL before trying to escape data.
Diffstat (limited to 'modules')
-rw-r--r--modules/extra/m_mysql.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp
index 5a2b7a5b0..85b18f151 100644
--- a/modules/extra/m_mysql.cpp
+++ b/modules/extra/m_mysql.cpp
@@ -339,9 +339,14 @@ Result MySQLService::RunQuery(const Query &query)
{
this->Lock.Lock();
- Anope::string real_query = this->BuildQuery(query);
+ if (!this->CheckConnection())
+ {
+ this->Lock.Unlock();
+ return MySQLResult(query, query.query, mysql_error(this->sql));
+ }
- if (this->CheckConnection() && !mysql_real_query(this->sql, real_query.c_str(), real_query.length()))
+ Anope::string real_query = this->BuildQuery(query);
+ if (!mysql_real_query(this->sql, real_query.c_str(), real_query.length()))
{
MYSQL_RES *res = mysql_store_result(this->sql);
unsigned int id = mysql_insert_id(this->sql);