1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 19:06:39 +02:00

Merge pull request #177 from attilamolnar/2.0+sqliteleak

m_sqlite: Fix possible memory leak when opening a database fails
This commit is contained in:
Adam
2016-09-25 14:37:01 -04:00
committed by GitHub
+10 -1
View File
@@ -138,7 +138,16 @@ SQLiteService::SQLiteService(Module *o, const Anope::string &n, const Anope::str
{
int db = sqlite3_open_v2(database.c_str(), &this->sql, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
if (db != SQLITE_OK)
throw SQL::Exception("Unable to open SQLite database " + database + ": " + sqlite3_errmsg(this->sql));
{
Anope::string exstr = "Unable to open SQLite database " + database;
if (this->sql)
{
exstr += ": ";
exstr += sqlite3_errmsg(this->sql);
sqlite3_close(this->sql);
}
throw SQL::Exception(exstr);
}
}
SQLiteService::~SQLiteService()