summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-15 20:17:06 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-15 20:17:06 +0000
commitb4480be526457da49dbcfeefd0d4071900a86f84 (patch)
tree4132cdf0d92095de94d40e488070e4802aca8d9a /src/modules
parent9d9c0553476e515550d9aa26e49b880f42dcc85e (diff)
Fix possible segfault if sql query failed. Using a free'd char is probably not a good thing.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6347 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_sqlite3.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp
index 5fba3880e..9c66c4f11 100644
--- a/src/modules/extra/m_sqlite3.cpp
+++ b/src/modules/extra/m_sqlite3.cpp
@@ -269,8 +269,7 @@ class SQLConn : public classbase
SQLConn(InspIRCd* SI, Module* m, const SQLhost& hi)
: Instance(SI), mod(m), host(hi)
{
- int result;
- if ((result = OpenDB()) == SQLITE_OK)
+ if (OpenDB() == SQLITE_OK)
{
Instance->Log(DEBUG, "Opened sqlite DB: " + host.host);
}
@@ -311,7 +310,6 @@ class SQLConn : public classbase
*
* The +1 is for null-terminating the string for mysql_real_escape_string
*/
-
query = new char[req.query.q.length() + (paramlen*2) + 1];
queryend = query;
@@ -344,7 +342,6 @@ class SQLConn : public classbase
*queryend = 0;
req.query.q = query;
- //Instance->Log(DEBUG, "<******> Doing query: " + ConvToStr(req.query.q.data()));
SQLite3Result* res = new SQLite3Result(mod, req.GetSource(), req.id);
res->dbid = host.id;
res->query = req.query.q;
@@ -356,11 +353,12 @@ class SQLConn : public classbase
sqlite3_update_hook(conn, QueryUpdateHook, &params);
if (sqlite3_exec(conn, req.query.q.data(), QueryResult, &params, &errmsg) != SQLITE_OK)
{
- Instance->Log(DEBUG, "Query failed: " + ConvToStr(errmsg));
+ std::string error(errmsg);
sqlite3_free(errmsg);
+ Instance->Log(DEBUG, "Query failed: " + ConvToStr(errmsg));
delete[] query;
delete res;
- return SQLerror(QSEND_FAIL, ConvToStr(errmsg));
+ return SQLerror(QSEND_FAIL, error);
}
Instance->Log(DEBUG, "Dispatched query successfully. ID: %d resulting rows %d", req.id, res->Rows());
delete[] query;