summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-08-17 14:08:30 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-08-17 14:08:30 +0200
commitc220a48593bf0fa7b3d31c802b6abcbea6a1eb46 (patch)
treef0181a48b58af2b9e2e9f6553e209ff865c92724 /src
parentc7a26bc21629ddd4103dac1ff7f9acf45a2c4d35 (diff)
m_sqlite3 Fix possible memory leak when opening a database fails
Diffstat (limited to 'src')
-rw-r--r--src/modules/extra/m_sqlite3.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp
index 1e3a65a18..47880c02c 100644
--- a/src/modules/extra/m_sqlite3.cpp
+++ b/src/modules/extra/m_sqlite3.cpp
@@ -90,8 +90,10 @@ class SQLConn : public SQLProvider
std::string host = tag->getString("hostname");
if (sqlite3_open_v2(host.c_str(), &conn, SQLITE_OPEN_READWRITE, 0) != SQLITE_OK)
{
- ServerInstance->Logs->Log("m_sqlite3",DEFAULT, "WARNING: Could not open DB with id: " + tag->getString("id"));
+ // Even in case of an error conn must be closed
+ sqlite3_close(conn);
conn = NULL;
+ ServerInstance->Logs->Log("m_sqlite3",DEFAULT, "WARNING: Could not open DB with id: " + tag->getString("id"));
}
}