aboutsummaryrefslogtreecommitdiff
path: root/src/shared/Database/SqlOperations.cpp
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-05-16 13:31:52 +0200
committerMachiavelli <none@none>2010-05-16 13:31:52 +0200
commit437a5d90b227921f84ce9b9ed11047b27ed09f17 (patch)
treed59d285581b8664b93f9fe8727f2bf3ff804f080 /src/shared/Database/SqlOperations.cpp
parent89887b9b6554656033079bd3c90e1495fb9edf74 (diff)
Fix a possible crash in SqlTransaction::Execute(), using post-iterating on the LockedQueue instead of pre-iterating.
Thanks to click for the insight and Spp for testing. --HG-- branch : trunk
Diffstat (limited to 'src/shared/Database/SqlOperations.cpp')
-rw-r--r--src/shared/Database/SqlOperations.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp
index c766d6ca21d..8894f896855 100644
--- a/src/shared/Database/SqlOperations.cpp
+++ b/src/shared/Database/SqlOperations.cpp
@@ -35,21 +35,32 @@ void SqlTransaction::Execute(Database *db)
{
const char* sql;
+ if (m_queue.empty())
+ return;
+
db->DirectExecute("START TRANSACTION");
- while (m_queue.next(sql))
+ while (!m_queue.empty())
{
+ sql = m_queue.peek();
+ m_queue.unlock();
if (!db->DirectExecute(sql))
{
free((void*)const_cast<char*>(sql));
+ m_queue.pop_front();
db->DirectExecute("ROLLBACK");
- while (m_queue.next(sql))
+ while (!m_queue.empty())
{
+ sql = m_queue.peek();
+ m_queue.unlock();
free((void*)const_cast<char*>(sql));
+ m_queue.pop_front();
}
+
return;
}
free((void*)const_cast<char*>(sql));
+ m_queue.pop_front();
}
db->DirectExecute("COMMIT");