From 3a18a6dcab45467e779e91c7b346aa3b148e8b9c Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Tue, 1 Oct 2024 23:04:25 -0500 Subject: Fix move assignment operators or delete them to prevent leaks. --- source/fud_sqlite.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'source/fud_sqlite.cpp') diff --git a/source/fud_sqlite.cpp b/source/fud_sqlite.cpp index 7ad8a12..f573f1c 100644 --- a/source/fud_sqlite.cpp +++ b/source/fud_sqlite.cpp @@ -49,6 +49,11 @@ SqliteDb::~SqliteDb() SqliteDb& SqliteDb::operator=(SqliteDb&& rhs) { + if (m_dbHandle != nullptr) { + sqlite3_close(m_dbHandle); + m_dbHandle = nullptr; + } + m_name = std::move(rhs.m_name); m_nameValid = rhs.m_nameValid; m_dbHandle = rhs.m_dbHandle; @@ -162,21 +167,6 @@ SqliteStatement::SqliteStatement(SqliteStatement&& rhs) : rhs.m_preparedStatement = nullptr; } -SqliteStatement& SqliteStatement::operator=(SqliteStatement&& rhs) -{ - m_input = std::move(rhs.m_input); - m_tail = rhs.m_tail; - m_status = rhs.m_status; - m_errorCode = rhs.m_errorCode; - m_preparedStatement = rhs.m_preparedStatement; - - rhs.m_tail = nullptr; - rhs.m_status = FudStatus::ObjectInvalid; - rhs.m_preparedStatement = nullptr; - - return *this; -} - SqliteStatement::~SqliteStatement() { if (m_preparedStatement != nullptr) { -- cgit v1.2.3