summaryrefslogtreecommitdiff
path: root/src/account-server/storage.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-09 23:26:03 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-09 23:26:03 +0100
commitae28fb2988badf1bceb7cbf85a89e6143d3d4536 (patch)
tree0188e3e6aff8234074d3d9e5369a164ff8c302dd /src/account-server/storage.cpp
parent48899866a768d1b8b1922dfc0eaf25490ad9d562 (diff)
downloadmanaserv-ae28fb2988badf1bceb7cbf85a89e6143d3d4536.tar.gz
manaserv-ae28fb2988badf1bceb7cbf85a89e6143d3d4536.tar.bz2
manaserv-ae28fb2988badf1bceb7cbf85a89e6143d3d4536.tar.xz
manaserv-ae28fb2988badf1bceb7cbf85a89e6143d3d4536.zip
Prevented a potential crash in storage::getAllWorldStateVars()
Minor other fixes. Trivial.
Diffstat (limited to 'src/account-server/storage.cpp')
-rw-r--r--src/account-server/storage.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 2326dec6..50b131b7 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -1509,6 +1509,14 @@ std::map<std::string, std::string> Storage::getAllWorldStateVars(int mapId)
{
std::map<std::string, std::string> variables;
+ // Avoid a crash because prepared statements must have at least one binding.
+ if (mapId < 0)
+ {
+ LOG_ERROR("getAllWorldStateVars was called with a negative map Id: "
+ << mapId);
+ return variables;
+ }
+
try
{
std::ostringstream query;
@@ -1527,7 +1535,7 @@ std::map<std::string, std::string> Storage::getAllWorldStateVars(int mapId)
mDb->bindValue(1, mapId);
const dal::RecordSet &results = mDb->processSql();
- for (unsigned int i = 0; i < results.rows(); i++)
+ for (unsigned int i = 0; i < results.rows(); ++i)
{
variables[results(i, 0)] = results(i, 1);
}
@@ -1588,7 +1596,7 @@ void Storage::setWorldStateVar(const std::string &name,
mDb->execSql(updateStateVar.str());
// If we updated a row, were finished here
- if (mDb->getModifiedRows() >= 1)
+ if (mDb->getModifiedRows() > 0)
return;
// Otherwise we have to add the new variable