diff options
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 4 | ||||
-rw-r--r-- | src/localconsts.h | 3 |
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 |