mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/DBLayer: Fixed memory leaks when query returned empty result set
This commit is contained in:
@@ -44,6 +44,7 @@ bool BasicStatementTask::Execute()
|
||||
ResultSet* result = m_conn->Query(m_sql);
|
||||
if (!result || !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
m_result.set(QueryResult(NULL));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,10 @@ class DatabaseWorkerPool
|
||||
ResultSet* result = conn->Query(sql);
|
||||
conn->Unlock();
|
||||
if (!result || !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
return QueryResult(NULL);
|
||||
}
|
||||
|
||||
result->NextRow();
|
||||
return QueryResult(result);
|
||||
@@ -275,7 +278,10 @@ class DatabaseWorkerPool
|
||||
delete stmt;
|
||||
|
||||
if (!ret || !ret->GetRowCount())
|
||||
{
|
||||
delete ret;
|
||||
return PreparedQueryResult(NULL);
|
||||
}
|
||||
|
||||
return PreparedQueryResult(ret);
|
||||
}
|
||||
|
||||
@@ -440,6 +440,7 @@ bool PreparedStatementTask::Execute()
|
||||
PreparedResultSet* result = m_conn->Query(m_stmt);
|
||||
if (!result || !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
m_result.set(PreparedQueryResult(NULL));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,12 @@ PreparedQueryResult SQLQueryHolder::GetPreparedResult(size_t index)
|
||||
|
||||
void SQLQueryHolder::SetResult(size_t index, ResultSet* result)
|
||||
{
|
||||
if (result && !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
/// store the result in the holder
|
||||
if (index < m_queries.size())
|
||||
m_queries[index].second.qresult = result;
|
||||
@@ -123,6 +129,12 @@ void SQLQueryHolder::SetResult(size_t index, ResultSet* result)
|
||||
|
||||
void SQLQueryHolder::SetPreparedResult(size_t index, PreparedResultSet* result)
|
||||
{
|
||||
if (result && !result->GetRowCount())
|
||||
{
|
||||
delete result;
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
/// store the result in the holder
|
||||
if (index < m_queries.size())
|
||||
m_queries[index].second.presult = result;
|
||||
|
||||
Reference in New Issue
Block a user