verify that the connection is open before trying to close it

This commit is contained in:
Chris Cromer 2022-11-03 15:36:08 -03:00
parent 31dca7e388
commit e9a72ea203
Signed by: cromer
GPG Key ID: FA91071797BEEEC2
2 changed files with 5 additions and 2 deletions

View File

@ -40,9 +40,12 @@ obelisk::KnowledgeBase::KnowledgeBase(const char* filename, int flags)
} }
obelisk::KnowledgeBase::~KnowledgeBase() obelisk::KnowledgeBase::~KnowledgeBase()
{
if (dbConnection_)
{ {
sqlite3_close_v2(dbConnection_); sqlite3_close_v2(dbConnection_);
} }
}
void obelisk::KnowledgeBase::createTable(std::function<const char*()> function) void obelisk::KnowledgeBase::createTable(std::function<const char*()> function)
{ {

View File

@ -15,7 +15,7 @@ namespace obelisk
const int DEFAULT_FLAGS const int DEFAULT_FLAGS
= SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
const char* filename_; const char* filename_;
sqlite3* dbConnection_; sqlite3* dbConnection_ = nullptr;
int flags_; int flags_;
void logSqliteError(int result); void logSqliteError(int result);