]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_sqlite3 Fix possible memory leak when opening a database fails
authorAttila Molnar <attilamolnar@hush.com>
Wed, 17 Aug 2016 12:08:30 +0000 (14:08 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 17 Aug 2016 12:08:30 +0000 (14:08 +0200)
src/modules/extra/m_sqlite3.cpp

index 1e3a65a18fdea27e4483daff11f05fd366534116..47880c02c51ef83a5585e886eabe11e94bda1b39 100644 (file)
@@ -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"));
                }
        }