Fix CID 1400763 Using invalid iterator (fixes issue #2806)

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-10-25 22:20:45 +02:00
parent cdd19d561b
commit 255d7c9675

View File

@ -432,7 +432,8 @@ ChoiceIterator::~ChoiceIterator() {
// are none left.
bool ChoiceIterator::Next() {
if (oemLSTM_ && LSTM_choices_ != nullptr && !LSTM_choices_->empty()) {
if (LSTM_choice_it_ != LSTM_choices_->end() && next(LSTM_choice_it_) == LSTM_choices_->end()) {
if (LSTM_choice_it_ == LSTM_choices_->end() ||
next(LSTM_choice_it_) == LSTM_choices_->end()) {
return false;
} else {
++LSTM_choice_it_;