summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-21 02:51:37 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-21 02:51:37 +0300
commite7ebc6c703cd31577bd78f7b133ba18c5dfab1a9 (patch)
treecac38b119279d8201d9026a359e3ea7f717628bb /src
parent985a6b7f5374f3d7310f3d6cec95874f2f3d81b8 (diff)
downloadmanaverse-e7ebc6c703cd31577bd78f7b133ba18c5dfab1a9.tar.gz
manaverse-e7ebc6c703cd31577bd78f7b133ba18c5dfab1a9.tar.bz2
manaverse-e7ebc6c703cd31577bd78f7b133ba18c5dfab1a9.tar.xz
manaverse-e7ebc6c703cd31577bd78f7b133ba18c5dfab1a9.zip
Fix possible crash in skill cooldowns.
Diffstat (limited to 'src')
-rw-r--r--src/gui/windows/skilldialog.cpp4
-rw-r--r--src/localconsts.h3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index c5eb45c02..a11e0b5aa 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -849,7 +849,7 @@ void SkillDialog::addSkillDuration(SkillInfo *const skill)
void SkillDialog::slowLogic()
{
- FOR_EACH (std::vector<SkillInfo*>::iterator, it, mDurations)
+ FOR_EACH_SAFE (std::vector<SkillInfo*>::iterator, it, mDurations)
{
SkillInfo *const skill = *it;
if (skill)
@@ -861,6 +861,8 @@ void SkillDialog::slowLogic()
skill->cooldown = 0;
skill->duration = 0;
skill->durationTime = 0;
+ if (it == mDurations.end())
+ return;
if (it != mDurations.begin())
-- it;
}
diff --git a/src/localconsts.h b/src/localconsts.h
index eee549789..6c52bf0e1 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -195,6 +195,9 @@
#define FOR_EACHP(type, iter, array) for (type iter = array->begin(), \
iter##_fend = array->end(); iter != iter##_fend; ++ iter)
+#define FOR_EACH_SAFE(type, iter, array) for (type iter = array.begin(); \
+ iter != array.end(); ++ iter)
+
#ifdef ENABLE_CHECKPLUGIN
#define A_NONNULLPOINTER __attribute__((nonnullpointer))
#else