Skip to content

Commit f9ca7f6

Browse files
committed
FIX: Linux Segfault through using temporary variable in std::find twice.
1 parent cd8db9f commit f9ca7f6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

CASAL2/source/AgeLengths/Age/Data.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ void Data::DoBuild() {
118118
<< " ages in the model";
119119
unsigned year = utilities::ToInline<string, unsigned>(row[0]);
120120
// Check year is valid
121-
if (find(model_->years().begin(), model_->years().end(), year) == model_->years().end())
121+
const vector<unsigned>& model_years = model_->years();
122+
if (find(model_years.begin(), model_years.end(), year) == model_years.end()) {
122123
LOG_WARNING_P(PARAM_DATA) << "year " << year << " is not in the model run years, so this age length will not be used";
124+
continue;
125+
}
123126

124127
for (unsigned i = 1; i < row.size(); ++i) {
125128
data_by_year_[year].push_back(utilities::ToInline<string, Double>(row[i]));

0 commit comments

Comments
 (0)