Skip to content

Commit

Permalink
Fixed possible wrong index usage
Browse files Browse the repository at this point in the history
  • Loading branch information
OneMoreGres committed Oct 17, 2018
1 parent bab4d63 commit 4109968
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion TranslatorHelper.cpp
Expand Up @@ -61,6 +61,9 @@ void TranslatorHelper::loadScripts () {
void TranslatorHelper::newItem (bool forceRotate) {
triesLeft_ = scripts_.size ();
currentIndex_ = forceRotate ? currentIndex_ + 1 : 0;
if (currentIndex_ >= scripts_.size ()) {
currentIndex_ = 0;
}
}

QString TranslatorHelper::nextScript () {
Expand All @@ -74,7 +77,10 @@ QString TranslatorHelper::nextScript () {
}

QString TranslatorHelper::currentScript () const {
return (triesLeft_ > 0 ? scripts_.at (currentIndex_) : QString ());
if (triesLeft_ > 0 && currentIndex_ < scripts_.size ()) {
return scripts_.at (currentIndex_);
}
return QString ();
}

bool TranslatorHelper::gotScripts () const {
Expand Down

0 comments on commit 4109968

Please sign in to comment.